Skip to main content

Process manager — a PM2 equivalent using launchd/systemd for persistence

Project description

macpmd

A process manager for macOS and Linux — a PM2 equivalent using launchd or systemd for persistence and crash recovery.

macpmd makes it easy to manage long-running processes. Start, stop, restart, and monitor processes from the command line. Processes are automatically registered with the system service manager (launchd on macOS, systemd on Linux) so they survive reboots and recover from crashes.

Features

  • Process management — add, start, stop, restart, and delete processes
  • Batch operations — operate on multiple processes at once, or use --all
  • Process listing — view all processes with status, PID, uptime, restart count, and service state
  • Log management — stdout/stderr redirected to ~/.local/share/macpmd/logs/ with automatic rotation
  • Log tailing — view recent output, follow in real-time, or show all process logs with coloured prefixes
  • Exit code logging — process exit codes and signals are recorded in the log
  • Service integration — launchd plists (macOS) or systemd units (Linux) auto-installed for boot persistence and crash recovery
  • Sudo support — start processes with --sudo for elevated privileges
  • Zero dependencies — stdlib only, no external packages required
  • Coloured output — TTY-aware ANSI colours for status display

Requirements

  • Python 3.12+
  • macOS (launchd) or Linux (systemd)

Installation

pip install macpmd

Or run directly with uv:

uvx macpmd

Quick Start

# Add a process (name auto-derived as "server")
macpmd add "node server.js"

# Add with an explicit name
macpmd add "python3 worker.py" --name my-worker

# Add with sudo
macpmd add "python3 server.py" --name my-app --sudo

# List all processes
macpmd list

# View logs
macpmd logs my-app
macpmd logs my-app --follow
macpmd logs --all
macpmd logs --all --follow

# Start a stopped process
macpmd start my-app

# Start all stopped processes
macpmd start --all

# Restart a process
macpmd restart my-app

# Stop multiple processes
macpmd stop my-app worker

# Stop all processes
macpmd stop --all

# Remove a process entirely
macpmd delete my-app

How It Works

macpmd spawns processes in new sessions (start_new_session) so they survive the parent terminal closing. Process state is tracked in ~/.local/share/macpmd/state.json and logs are written to ~/.local/share/macpmd/logs/<name>.log.

When you add a process, a service file is automatically installed:

macOS (launchd)

A plist is installed in ~/Library/LaunchAgents/ (or /Library/LaunchDaemons/ for --sudo) with:

  • KeepAlive: true — launchd restarts the process if it crashes
  • RunAtLoad: true — the process starts automatically at login

Linux (systemd)

A unit file is installed in ~/.config/systemd/user/ (or /etc/systemd/system/ for --sudo) with:

  • Restart=always — systemd restarts the process if it crashes
  • WantedBy=default.target — the process starts automatically at login

This gives you PM2-style process management backed by your platform's native process supervisor.

Development

# Set up development environment
make dev

# Run linting and type checking
make check

# Auto-format code
make format

# Build wheel and docs
make build

Licence

Released under the Unlicense — public domain.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

macpmd-1.0.0b8-py3-none-any.whl (38.0 kB view details)

Uploaded Python 3

File details

Details for the file macpmd-1.0.0b8-py3-none-any.whl.

File metadata

  • Download URL: macpmd-1.0.0b8-py3-none-any.whl
  • Upload date:
  • Size: 38.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.2

File hashes

Hashes for macpmd-1.0.0b8-py3-none-any.whl
Algorithm Hash digest
SHA256 13ece019e2e3385b33d33a0a2e0c5e008170c2b3fcd591408c8d2f9d6476aa4a
MD5 08d698ddffe1ff4f66909bdd78790260
BLAKE2b-256 dd4d744a36ee7910cedabf0f55ce00b7b9ea287df92a4827177e7e357098a4b9

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page