Process Compose

Process compose is a lightweight utility for building custom workflows and execution sequences. It is optimized for:
- Parallelizing processes execution
- Defining execution dependencies and order
- Defining recovery policies (restart
on-failure, always, no)
- Declaring processes arguments
- Declaring processes environment variables
It is heavily inspired by docker-compose, but without the need for containers. The configuration syntax tries to follow the docker-compose specifications, with a few minor additions and lots of subtractions.
Installation
- Go to the releases, download the package for your OS, and copy the binary to somewhere on your PATH.
Documentation
- See examples of workflows for best practices
- See below
List of Features and Planned Features
β
Mostly implemented
β Implementation not started (Your feedback and β will motivate further development π)
β
Launcher
β
Parallel
process1:
command: "sleep 3"
process2:
command: "sleep 3"
β
Serial
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
β Instance Number
β
Define process dependencies
process2:
depends_on:
process2:
condition: process_completed_successfully # or "process_started" (default)
process3:
condition: process_completed_successfully
β
Output Handling
β
Show process name
β
Different colors per process
β
StdErr is printed in Red
β Silence specific processes
β
TUI (Terminal User Interface)
β
Review processes status
β
Start processes (only completed or disabled)
β
Stop processes
β
Review logs
TUI is the default run mode, but it's possible to disable it:
./process-compose -t=false
β
Logger
β
Per Process Log Collection
process2:
log_location: ./pc.process2.log #if undefined or empty no logs will be saved
β
Capture StdOut output
β
Capture StdErr output
β
Merge into a single file
processes:
process2:
command: "chmod 666 /path/to/file"
environment:
- 'ABC=42'
log_location: ./pc.global.log #if undefined or empty no logs will be saved (if also not defined per process)
β Silence specific processes
β
Process compose console log level
log_level: info # other options: "trace", "debug", "info", "warn", "error", "fatal", "panic"
processes:
process2:
command: "chmod 666 /path/to/file"
This setting controls the process-compose log level. The processes log level should be defined inside the process. It is recommended to support its definition with an environment variable that can be defined in process-compose.yaml
β Health Checks
β Is Alive
β Is Ready
β Auto Restart if not healthy
β
Auto Restart on exit
process2:
availability:
restart: on-failure # other options: "always", "no" (default)
backoff_seconds: 2 # default: 1
max_restarts: 5 # default: 0 (unlimited)
β
Environment Variables
β
Per Process
process2:
environment:
- 'I_AM_LOCAL_EV=42'
β
Global
processes:
process2:
command: "chmod 666 /path/to/file"
environment:
- 'I_AM_LOCAL_EV=42'
environment:
- 'I_AM_GLOBAL_EV=42'
Default environment variables:
PC_PROC_NAME - Defines the process name as defined in the process-compose.yaml file.
PC_REPLICA_NUM - Defines the process replica number. Useful for port collision avoidance for processes with multiple replicas.
β
REST API
A convenient Swagger API is provided: http://localhost:8080/swagger/index.html
β
Configuration
β
Support .env file
β
Override ${var} and $var from environment variables or .env values
β Merge 2 or more configuration files with override values
β
Specify which configuration files to use
process-compose -f "path/to/process-compose-file.yaml"
β
Auto discover configuration files
The following discovery order is used: compose.yml, compose.yaml, process-compose.yml, process-compose.yaml. If multiple files are present the first one will be used.
β
Linux
The default backend is bash. You can define a different backend with a SHELL environment variable.
β
Windows
The default backend is cmd. You can define a different backend with a SHELL environment variable.
process1:
command: "python -c print(str(40+2))"
#note that the same command for bash/zsh would look like: "python -c 'print(str(40+2))'"
Using powershell backend had some funky behaviour (like missing command1 && command2 functionality in older versions). If you need to run powershell scripts, use the following syntax:
process2:
command: "powershell.exe ./test.ps1 arg1 arg2 argN"
β macOS