A tutorial on adding a live status page with uptime history and incident tracking to a python background worker in under five minutes.
The Easiest Way to Add a Status Page Dashboard to Your Python Worker
A background worker — a queue processor, a scheduled job runner, an API poller — usually has no visibility layer at all. It either works or it doesn't, and finding out which one requires checking logs or SSHing into wherever it runs. This tutorial covers the fastest way to give any Python worker a real status page: uptime history, incident tracking, and live status, without building any of it yourself.
Table of Contents
- What "Status Page" Actually Means Here
- Step 1: Install StayPresent
- Step 2: Wrap Your Worker Script
- Step 3: That's It — Check
/status - Step 4 (Optional): Customize the Page
- Step 5 (Optional): Name Your Worker
- Step 6 (Optional): Restrict Admin Detail
- Deploying It Somewhere Real
- FAQs
- Conclusion
What "Status Page" Actually Means Here
This isn't a static "everything's fine" placeholder page. It's a real dashboard: per-service uptime percentages over 24 hours, 7 days, and 30 days, a merged incident history (crashes, restarts, recoveries), and live current status — all generated automatically from data your worker's supervisor already has, with nothing hand-built.
Step 1: Install StayPresent
pip install staypresent[prod]
Step 2: Wrap Your Worker Script
Your existing worker — worker.py, doing whatever it already does — doesn't need any changes:
# main.py
import staypresent
staypresent.run("worker.py")
Step 3: That's It — Check /status
This is genuinely the entire minimum setup. Run main.py, and a full status page is already live at http://localhost:8080/status — uptime tracking, incident history, everything, with zero additional configuration.
import staypresent
staypresent.run("worker.py")
# /status is live immediately, no extra code needed
Step 4 (Optional): Customize the Page
If you want it branded rather than generic:
import staypresent
staypresent.web.status(
title="Data Pipeline Status",
copyright="Your Team",
footer_links=[{"label": "Docs", "url": "https://example.com/docs"}],
mode="dark",
)
staypresent.run("worker.py")
Step 5 (Optional): Name Your Worker
By default, the status page shows your worker by its filename. For something more readable:
staypresent.run(
"worker.py",
services_name="Queue Processor",
services_description="Handles incoming job batches",
)
Step 6 (Optional): Restrict Admin Detail
The public page shows overall status and uptime by default. If you want the deeper detail — exit codes, a recent log tail — locked behind a key rather than the auto-generated one:
import os
import staypresent
staypresent.web.status(
api_key=os.getenv("STATUS_ADMIN_KEY"),
)
staypresent.run("worker.py")
Deploying It Somewhere Real
The exact same code works whether you're testing locally or deploying to Render, Railway, Koyeb, or a VPS — just make sure to read the platform's assigned port dynamically:
import os
import staypresent
staypresent.web.status(title="Data Pipeline Status")
staypresent.run(
"worker.py",
port=int(os.getenv("PORT", 8080)),
)
FAQs
Do I need a database for the uptime history?
No — everything shown is derived from data already tracked in-process for crash recovery; there's no separate storage to set up.
Can I add a status page to multiple workers at once?
Yes — pass a list or use bots=[...] in run(), and each worker gets its own row on the same page automatically.
Is the status page accessible without any login?
The overall status, uptime, and incident summaries are public by design, the same as any real status page. Deeper technical detail (exit codes, log tails) is gated behind an optional admin key.
Conclusion
Adding a real status dashboard to a Python worker doesn't require building anything — staypresent.run("worker.py") alone gets you a live page at /status with genuine uptime and incident tracking, and a couple of optional lines let you brand it and control what's public versus admin-only.
pip install staypresent[prod]
Top comments (0)