Comparing StayPresent, Supervisor, and PM2 for python process management — setup, crash recovery, HTTP port handling, and when each fits.
StayPresent vs Supervisor vs PM2 for Python Bot Process Management
Supervisor and PM2 are two of the most established tools for python process management — keeping a process running, restarting it on crash, managing logs. Both predate StayPresent by years and are proven, widely-used tools. But neither was built with the specific PaaS-deployment problem in mind: satisfying a hosting platform's HTTP port requirement. Here's how all three actually compare for the common case of deploying a bot.
Table of Contents
- What Each Tool Is Actually For
- Installation and Setup
- Configuration Style
- Crash Recovery Comparison
- The HTTP Port Problem
- Logging Comparison
- Comparison Table
- When Each Tool Is the Right Choice
- FAQs
- Conclusion
What Each Tool Is Actually For
Supervisor is a mature, Python-based process control system, originally designed for Unix-like systems, that manages arbitrary processes via a config file and a control daemon (supervisord). It's general-purpose — it doesn't care whether the process is Python, Node, or a shell script.
PM2 is a Node.js process manager, widely used for Node apps but also commonly used to run Python scripts, offering restart-on-crash, log management, and a built-in monitoring dashboard.
StayPresent is a Python package, not a system-level daemon — it runs inside your own Python process, launching your bot as a subprocess it directly supervises, while also running an HTTP server specifically to satisfy PaaS hosting requirements.
Installation and Setup
Supervisor requires a system-level install and a separate config file, typically outside your project's own codebase:
; /etc/supervisor/conf.d/mybot.conf
[program:mybot]
command=python bot.py
autorestart=true
sudo apt install supervisor
sudo supervisorctl reread
sudo supervisorctl update
PM2 requires Node.js itself as a dependency, even to run a Python script:
npm install -g pm2
pm2 start bot.py --interpreter python3
StayPresent is a pure Python dependency, installed and configured entirely within your own script:
pip install staypresent[prod]
import staypresent
staypresent.run("bot.py")
Configuration Style
Supervisor's configuration lives in a separate .ini-style file, generally outside version control unless you specifically arrange for it (and outside your application's own deploy artifact on most PaaS platforms, which don't give you system-level config access at all). PM2 configuration can live in an ecosystem.config.js file or be passed via CLI flags. StayPresent's configuration is just Python function arguments, living directly in your own entry-point script:
staypresent.run(
"bot.py",
restart_on_crash=True,
max_restarts=5,
restart_delay=2.0,
)
This matters specifically on PaaS platforms like Render, Railway, or Koyeb, which typically don't give you access to install and configure a system daemon like Supervisor at all — your deployment is just "run this command," which is exactly the model StayPresent fits into.
Crash Recovery Comparison
All three tools handle crash recovery, though with different granularity:
-
Supervisor supports
autorestart,startretries, and backoff timing, configured per-program in its.inifile. -
PM2 supports
--restart-delay,max_restarts, and exponential backoff, configured via CLI flags or its ecosystem file. -
StayPresent supports
restart_on_crash,max_restarts,restart_delay, andrestart_reset_after— the last of which specifically resets the crash counter after a period of sustained uptime, avoiding a slow accumulation toward the restart ceiling from unrelated, infrequent crashes.
Functionally, all three solve the core problem. The difference is entirely about where that configuration lives and what environment it assumes.
The HTTP Port Problem
This is the actual differentiator for PaaS deployment specifically. Neither Supervisor nor PM2 has any concept of an HTTP health-check port — they're process managers, full stop. If your hosting platform requires a bound HTTP port to consider a deployment healthy, using Supervisor or PM2 alone still leaves you writing a separate Flask (or equivalent) server yourself, exactly like the "custom Flask server" approach covered in other comparisons.
StayPresent bundles both concerns into one call:
staypresent.web.json({"status": "running"})
staypresent.run("bot.py") # HTTP server + process supervision, together
Logging Comparison
Supervisor writes process stdout/stderr to log files it manages itself, configurable per-program. PM2 provides its own log aggregation and a pm2 logs command. StayPresent logs its own orchestration events (crashes, restarts, shutdowns) through a dedicated "staypresent" Python logger that never touches the root logger — your bot's own stdout/stderr, meanwhile, is inherited normally from the subprocess, the same as it would be under Supervisor or PM2.
Comparison Table
| Feature | Supervisor | PM2 | StayPresent |
|---|---|---|---|
| Requires system-level install | Yes | Yes (+ Node.js) | No — pure Python package |
| Works on most PaaS platforms | Rarely (no daemon access) | Rarely (no daemon access) | Yes, by design |
| Built-in HTTP health endpoint | No | No | Yes |
| Config location | Separate .ini file |
CLI / ecosystem file | Python code in your script |
| Crash counter reset after uptime | No | Partial (backoff-based) | Yes (restart_reset_after) |
| Language dependency | Python-agnostic | Requires Node.js | Native Python |
When Each Tool Is the Right Choice
Supervisor remains an excellent choice on a VPS or bare-metal server where you have full system access and want to manage several unrelated processes (not just Python) under one consistent tool. PM2 makes sense if you're already running a Node.js stack alongside a Python script and want one process manager for both. StayPresent is the better fit specifically for PaaS deployments — Render, Railway, Koyeb, Heroku — where you don't have system daemon access at all, and where the HTTP port requirement is the actual problem you're solving, not just process supervision in isolation.
FAQs
Can I use Supervisor or PM2 together with StayPresent?
On a VPS, yes — Supervisor or PM2 could supervise the outer python main.py process (which itself runs StayPresent), giving you a second, outer restart layer on top of StayPresent's own bot-subprocess supervision.
Does StayPresent replace Supervisor entirely on a VPS?
Not necessarily — Supervisor's system-level features (managing multiple unrelated services, log rotation, a control CLI) go beyond what StayPresent aims to do, which is specifically bot-process supervision plus an HTTP port.
Is PM2 a reasonable choice for a pure-Python project?
It works, but it introduces a Node.js dependency purely to manage a Python process — StayPresent avoids that entirely for projects that are otherwise pure Python.
Conclusion
Supervisor and PM2 are solid, mature tools for python process management in environments where you control the underlying system. But most PaaS platforms don't grant that kind of access, and neither tool addresses the HTTP-port health-check requirement those platforms impose. StayPresent solves both problems together, as a pure Python dependency that fits directly into your bot's own entry point.
pip install staypresent[prod]
Top comments (0)