Skip to main content

pm5 (Process Manager) - README

Overview

pm5 is a Python package inspired by pm2, designed to easily manage multiple services and their configurations. It is particularly useful for advanced scenarios where precise control over CPU usage, service monitoring, and automatic restarts are required. This package was created to overcome limitations in managing multiple Celery queues and workers, allowing for more granular control of allocated CPU.

pm5 is a simple tool for developers and system administrators who need advanced control over multiple services and their configurations. Its ability to manage resources, automate restarts, and handle graceful shutdowns makes it an essential tool for complex service management scenarios.

Use Cases

  • Managing Multiple Celery Queues: Gain fine-grained control over the number of workers per queue, overcoming limitations of Celery's worker management.
  • Service Stack Management: Manage and configure multiple services as a single stack, simplifying the deployment and monitoring process.
  • Advanced Resource Management: Allocate CPU resources more effectively across multiple services, ensuring optimal performance and resource utilization.

Features

  • Service Management: Start, stop, and monitor multiple services with ease.
  • Advanced CPU Management: Control the number of instances per service based on CPU availability.
  • Automatic Restarts: Automatically restart services on failure with configurable restart limits.
  • Environment Management: Pass specific environment variables to each service.
  • Graceful Shutdown: Handle graceful shutdowns and cleanups of services.
  • Configuration Flexibility: Easily configure services through a JSON ecosystem file.

Installation

pip install pm5

Configuration

Create an ecosystem configuration file (e.g., ecosystem.config.json) to define the services you want to manage.

Example ecosystem.config.json

{
  "services": [
    {
      "name": "Test Application 1",
      "interpreter": "python3.9",
      "interpreter_args": [],
      "script": "test.py",
      "args": [],
      "instances": 1,
      "wait_ready": true,
      "autorestart": true,
      "max_restarts": 3,
      "env": {
        "ENV_VAR": "value"
      },
      "disabled": false
    }
  ]
}

Configuration Fields

Field Type Example Description
disabled boolean false Enable or disable the service
name string Test Application 1 The name of the service used for debugging
interpreter string python3.9 The path to the interpreter
interpreter_args string[] [] The args passed to the interpreter
script string test.py The script to call
args string[] [] The args passed to the script
instances number 1 The number of instances of the script to run
wait_ready boolean true Wait for the service to load before continuing to the next service
autorestart boolean true Automatically restart the service
max_restarts number 3 The number of times to autorestart the service if failure before exiting
env object {} An object of environment key values that should be passed to the script

Usage

Help

❯ pm5 --help
usage: pm5 [-h] {start,stop} ...

Like pm2 but without node.js.

positional arguments:
  {start,stop}
    start       Start the process manager daemon
    stop        Stop the process manager daemon

optional arguments:
  -h, --help    show this help message and exit

Start the stack as a daemon

pm5 start

Stop the daemonized stack

pm5 stop

Start the app without daemonizing

pm5 start --debug

Metadata

Release files for pm5 0.1.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pm5 0.1.4
File Size Uploaded
pm5-0.1.4.tar.gz 9.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for pm5 0.1.4
File Interpreter ABI Platform
pm5-0.1.4-py3-none-any.whl Python 3 none any Details

Total release size: 18.7 kB

Release files / pm5-0.1.4.tar.gz

Download URL pm5-0.1.4.tar.gz
Size 9.5 kB
Tags Source
SHA-256 checksum
How to use checksums
06ca777f064eec22c6e5cc7d05f556844b6793b355a34cfb108eee80f7a18d22
BLAKE2b-256 checksum
How to use checksums
f9a018729342e4af9a9485bbaa21be65e20f150f89d041131c17b08b94158d12
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.8.3 CPython/3.10.12 Linux/6.8.0-1014-azure

Release files / pm5-0.1.4-py3-none-any.whl

Download URL pm5-0.1.4-py3-none-any.whl
Size 9.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
888a087d57e01e1aeb2e75e4687bcc445919571678abb858d2c8d6bf74539578
BLAKE2b-256 checksum
How to use checksums
c7aff59e80e001ac8ada2750601a833c2f0fb89e33ff2c3580ab5e0284b5e001
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.8.3 CPython/3.10.12 Linux/6.8.0-1014-azure

Release history Release notifications | RSS feed

This release

0.1.4 This release

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

2 release files

0.0.12

2 release files

0.0.11

2 release files

0.0.10

2 release files

0.0.9

2 release files

0.0.7

2 release files

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page