Process Compose 是一个简单而灵活的调度程序和编排器,用于管理非容器化应用程序。
它深受docker-compose的启发,但不需要容器。不必处理 docker 文件、卷定义、网络和 docker 注册表
配置语法尝试遵循 docker-compose 规范,进行了一些小的添加和大量的删减。
特征:
进程执行(并行或/和串行)
处理依赖关系和启动顺序
进程恢复策略
手动进程[重新]启动
处理参数bash或zsh样式(或定义您自己的 shell)
每个进程和全局环境变量
每个进程或全局(单个文件)日志
健康检查(活性和准备情况)
终端用户界面 (TUI) 或 CLI 模式
分叉(服务或守护进程)进程
REST API(OpenAPI 又名 Swagger)
日志缓存
既可以作为服务器又可以作为客户端
可配置的快捷键
合并配置文件
命名空间
运行一个进程的多个副本
并行启动:
processes:
process1:
description: This process will sleep for 2 seconds
command: "sleep 3" process2:
description: This process will sleep for 3 seconds
command: "sleep 3"'
串行启动
processes:
process1:
command: "sleep 3" depends_on:
process2:
condition: process_completed_successfully # or "process_completed" if you don't care about errors
process2:
command: "sleep 3" depends_on:
process3:
condition: process_completed_successfully # or "process_completed" if you don't care about errors
进程的多个副本
您可以通过添加参数来运行进程的多个副本processes.process_name.replicas(默认值:1)
processes:
process_name:
command: "sleep 2" log_location: ./log_file.{PC_REPLICA_NUM}.log # <- {PC_REPLICA_NUM} will be replaced with replica number. If more than one replica and PC_REPLICA_NUM is not specified, the replica number will be concatenated to the file end.
replicas: 2
指定工作目录
processes:
process1:
command: "ls -laF --color=always" working_dir: "/path/to/your/working/directory"
定义流程依赖关系
processes:
process2:
depends_on:
process3:
condition: process_completed_successfully
process4:
condition: process_completed_successfully
后台(独立)进程
processes:
nginx:
command: "docker run -d --rm --name nginx_test nginx" # note the '-d' for detached mode
is_daemon: true # this flag is required for background processes (default false)
shutdown:
command: "docker stop nginx_test" timeout_seconds: 10 # default 10
signal: 15 # default 15, but only if command is not defined or empty
退出时自动重新启动
processes:
process2:
availability:
restart: on_failure # other options: "exit_on_failure", "always", "no" (default)
backoff_seconds: 2 # default: 1
max_restarts: 5 # default: 0 (unlimited)
活性探针
processes:
nginx:
command: "docker run -d --rm -p80:80 --name nginx_test nginx" is_daemon: true
shutdown:
command: "docker stop nginx_test" signal: 15
timeout_seconds: 5
liveness_probe:
exec:
command: "[ $(docker inspect -f '{{.State.Running}}' nginx_test) = 'true' ]" working_dir: /tmp # if not specified the process working dir will be used
initial_delay_seconds: 5
period_seconds: 2
timeout_seconds: 5
success_threshold: 1
failure_threshold: 3
就绪探针
processes:
nginx:
command: "docker run -d --rm -p80:80 --name nginx_test nginx" is_daemon: true
shutdown:
command: "docker stop nginx_test" readiness_probe:
http_get:
host: 127.0.0.1
scheme: http
path: "/" port: 80
initial_delay_seconds: 5
period_seconds: 10
timeout_seconds: 5
success_threshold: 1
failure_threshold: 3
https://www.jdon.com/70235.html