Skip to main content

Cross-platform command-as-service manager for Windows, Linux systemd, and macOS launchd.

Project description

py-simple-service-manager

py-simple-service-manager lets you manage a one-line command as a service on Linux, Windows, and macOS.

The same Python runner handles command execution, retry attempts, status files, and stdout/stderr logs. Platform backends only register and control the runner:

  • Linux: systemd units controlled by systemctl
  • Windows: Task Scheduler tasks controlled by schtasks and PowerShell
  • macOS: launchd agents/daemons controlled by launchctl

Install

python -m pip install -e .

Administrator relaunch support uses py-admin-launch for Windows UAC, Linux pkexec/sudo, and macOS osascript/sudo.

Startup modes

  • manual: do not start at boot.
  • auto: start once at boot after network components are available.
  • auto-retry: start at boot and retry after K seconds up to N times when the command exits with a non-zero code.

The retry count is handled by this package's runner, so it works consistently across all supported platforms.

pssm logs and the GUI log tabs read the current log files, not only completed runs. The runner flushes stdout/stderr to disk as bytes arrive, and Python commands are launched with unbuffered output automatically.

Usage

Register a manual service:

pssm add api -- python -m http.server 9000

Register a boot service:

pssm add api --mode auto -- python -m http.server 9000

Register a boot service with retry:

pssm add worker --mode auto-retry --retry-delay 10 --retry-limit 5 -- python worker.py

Set a per-run timeout, or use None for no time limit:

pssm add api --timeout 30 -- python -m http.server 9000
pssm edit api --timeout None

Change startup mode later:

pssm mode worker manual
pssm mode worker auto-retry --retry-delay 10 --retry-limit 5

Inspect and control services:

pssm list
pssm status worker
pssm logs worker
pssm logs worker --stream stderr --lines 100
pssm start worker
pssm stop worker
pssm remove worker

Edit the same fields exposed by the GUI:

pssm edit worker --command "python worker.py --queue default" --cwd /path/to/app
pssm edit worker --mode auto-retry --retry-delay 10 --retry-limit 5 --timeout 60
pssm edit worker --clear-cwd

Open the GUI:

pssm gui
pssm-gui

The GUI supports listing services, creating services, editing command/startup mode/retry settings/timeout/working directory, deleting services, starting and force-stopping services, viewing stdout/stderr, and viewing start history. The selected service status shows whether the current run is still active and how many seconds it has been running. Anything the GUI can change is also available through the CLI.

Show storage paths and platform details:

pssm doctor

Services are managed in system scope. Commands relaunch with administrator/root privileges automatically when needed.

Platform notes

Linux

Linux requires systemd and systemctl.

  • System scope writes units to /etc/systemd/system.
  • Boot startup uses network-online.target with Wants= and After=.

Windows

Windows uses Task Scheduler.

  • Services are registered as system tasks:
pssm add name --mode auto -- your-command

System-scope tasks run as SYSTEM with highest available privileges. Make sure the command and Python environment are available to that account.

macOS

macOS uses launchd.

  • System scope writes LaunchDaemons to /Library/LaunchDaemons.
  • Boot startup maps to RunAtLoad=true.

Development

Run tests from source:

PYTHONPATH=src python -m unittest discover -s tests -v

On Windows PowerShell:

$env:PYTHONPATH = "src"
python -m unittest discover -s tests -v

Project details


Download files

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

Source Distribution

py_simple_service_manager-0.1.15.tar.gz (168.1 kB view details)

Uploaded Source

Built Distribution

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

py_simple_service_manager-0.1.15-py3-none-any.whl (235.6 kB view details)

Uploaded Python 3

File details

Details for the file py_simple_service_manager-0.1.15.tar.gz.

File metadata

  • Download URL: py_simple_service_manager-0.1.15.tar.gz
  • Upload date:
  • Size: 168.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.4.1 CPython/3.11.15 Windows/10

File hashes

Hashes for py_simple_service_manager-0.1.15.tar.gz
Algorithm Hash digest
SHA256 3702bd93b10debae86b5c5ca97e229105939910792fd86fdaa86f7983df0bad6
MD5 01a736581984e32d10f4a8f7fb258ac0
BLAKE2b-256 63b5234427a1df19bfe4f85c7399f19e6fe15f5e143508454be688a0d177a1c2

See more details on using hashes here.

File details

Details for the file py_simple_service_manager-0.1.15-py3-none-any.whl.

File metadata

File hashes

Hashes for py_simple_service_manager-0.1.15-py3-none-any.whl
Algorithm Hash digest
SHA256 ad72ae2af715d58f1b6c80aeeb2bb39355aff179c4fe0c8f2c7b5749359cec00
MD5 cfbe6067528c0cee3dc4f7092839197a
BLAKE2b-256 6ce1e614629162fff619368510cb62d3ec7f0d365e3d091e7aa9a956c452400f

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