process-compose

module
v0.10.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 7, 2022 License: Apache-2.0

README ΒΆ

Process Compose

made-with-Go Maintenance PRs Welcome Go Report Releases

Process Compose is a simple and flexible scheduler and orchestrator to manage non-containerized applications.

Why? Because sometimes you just don't want to deal with docker files, volume definitions, networks and docker registries.

Main use cases would be:

  • Processes execution (in parallel or serially)
  • Defining processes dependencies and startup order
  • Defining recovery policies (restart on-failure, always, no). Manual recovery is also supported.
  • 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.

TUI

Quick Start

Imaginary system diagram:

Diagram

process-compose.yaml definitions for the system above:

version: "0.5"

environment:
  - 'GLOBAL_ENV_VAR=1'
log_location: /path/to/combined/output/logfile.log
log_level: debug

processes:
  Manager:
    command: "/path/to/manager"
    availability:
      restart: "always"
    depends_on:
      ClientA:
        condition: process_started
      ClientB:
        condition: process_started

  ClientA:
    command: "/path/to/ClientA"
    availability:
      restart: "always"
    depends_on:
      Server_1A:
        condition: process_started
      Server_2A:
        condition: process_started
    environment:
      - 'LOCAL_ENV_VAR=1'

  ClientB:
    command: "/path/to/ClientB -some -arg"
    availability:
      restart: "always"
    depends_on:
      Server_1B:
        condition: process_started
      Server_2B:
        condition: process_started
    environment:
      - 'LOCAL_ENV_VAR=2'

  Server_1A:
    command: "/path/to/Server_1A"
    availability:
      restart: "always"

  Server_2A:
    command: "/path/to/Server_2A"
    availability:
      restart: "always"

  Server_1B:
    command: "/path/to/Server_1B"
    availability:
      restart: "always"

  Server_2B:
    command: "/path/to/Server_2B"
    availability:
      restart: "always"

Finally, run process-compose in the process-compose.yaml directory. Or give it a direct path:

process-compose -f /path/to/process-compose.yaml

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
output
❌ 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

Control the UI log buffer size:

log_level: info
log_length: 1200 #default: 1000
processes:
  process2:
    command: "ls -R /"

Note: Using a too large buffer will put a significant penalty on your CPU.

βœ… 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

Swagger
βœ… 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.

βœ… Multi-platform
βœ… 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

Directories ΒΆ

Path Synopsis
src
api
app
docs
Package docs GENERATED BY SWAG; DO NOT EDIT This file was generated by swaggo/swag
Package docs GENERATED BY SWAG; DO NOT EDIT This file was generated by swaggo/swag
tui

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
JackTT - Gopher πŸ‡»πŸ‡³