Harden Raspberry Pi 24/7 operation with systemd resilience, health probes, archival, and recovery tooling#12
Draft
Copilot wants to merge 2 commits into
Draft
Harden Raspberry Pi 24/7 operation with systemd resilience, health probes, archival, and recovery tooling#12Copilot wants to merge 2 commits into
Copilot wants to merge 2 commits into
Conversation
Agent-Logs-Url: https://github.com/nexuspcs/ConnectivityMonitor/sessions/5be8d40f-972c-4648-b122-7c01afdd1f28 Co-authored-by: nexuspcs <69493073+nexuspcs@users.noreply.github.com>
…tion Agent-Logs-Url: https://github.com/nexuspcs/ConnectivityMonitor/sessions/5be8d40f-972c-4648-b122-7c01afdd1f28 Co-authored-by: nexuspcs <69493073+nexuspcs@users.noreply.github.com>
Copilot created this pull request from a session on behalf of
nexuspcs
May 14, 2026 05:45
View session
There was a problem hiding this comment.
Pull request overview
This PR adds an “always-on” operational model for the Python Connectivity Monitor on Raspberry Pi by introducing systemd hardening, periodic health probing, daily artifact archiving, and a recovery helper script, along with updated operational documentation.
Changes:
- Hardened the main
connectivity-monitor@.serviceunit for long-running, resilient operation. - Added systemd timer-driven health probes (
/api/status) and daily log/report archival + pruning. - Added recovery/validation tooling and expanded deployment/operations documentation for 24/7 Pi setups.
Reviewed changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| README.md | Mentions the new 24/7 ops units/tools at the top level. |
| python/connectivity-monitor@.service | Updates the main monitor systemd unit with restart behavior and sandboxing/hardening options. |
| python/systemd/connectivity-monitor-healthcheck@.service | Adds a oneshot systemd unit to run the API health probe. |
| python/systemd/connectivity-monitor-healthcheck@.timer | Schedules the health probe to run periodically. |
| python/systemd/connectivity-monitor-archive@.service | Adds a oneshot systemd unit to run log/report archival + pruning. |
| python/systemd/connectivity-monitor-archive@.timer | Schedules daily archival rotation. |
| python/ops/health_probe.py | Implements /api/status probing with stateful consecutive-failure tracking and optional reboot triggering. |
| python/ops/archive_artifacts.py | Implements tar.gz archival of logs/reports plus retention pruning. |
| python/ops/recover_service.sh | Adds a one-command systemd recovery + API validation helper. |
| python/README.md | Expands Raspberry Pi production setup and operational guidance (healthcheck, archival, recovery, soak tests). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| UMask=0027 | ||
| LimitNOFILE=65536 | ||
| TasksMax=512 | ||
| NoNewPrivileges=true |
| [Unit] | ||
| Description=Connectivity Monitor API health probe for %i | ||
| After=connectivity-monitor@%i.service | ||
| Requires=connectivity-monitor@%i.service |
Comment on lines
+13
to
+16
| if [[ -z "${PORT}" ]]; then | ||
| CONFIG_PATH="/home/${USER_NAME}/ConnectivityMonitor/monitor_config.json" | ||
| if [[ -f "${CONFIG_PATH}" ]]; then | ||
| if ! PORT="$(python3 - "${CONFIG_PATH}" <<'PY' |
Comment on lines
+43
to
+49
| for name in os.listdir(archive_dir): | ||
| if not name.endswith(".tar.gz"): | ||
| continue | ||
| full = os.path.join(archive_dir, name) | ||
| if os.path.isfile(full) and (now - os.path.getmtime(full)) > max_age: | ||
| os.remove(full) | ||
| removed += 1 |
Comment on lines
+184
to
+190
| Keep the monitor on localhost and publish through a reverse proxy (Nginx/Caddy/Traefik) to add: | ||
|
|
||
| - HTTPS/TLS certificates | ||
| - Basic auth or SSO | ||
| - IP allow-listing/rate limits | ||
|
|
||
| Proxy upstream target: `http://127.0.0.1:8080` |
Comment on lines
+119
to
+120
| - `python/systemd/connectivity-monitor-healthcheck@.service|.timer` (scheduled API health probe) | ||
| - `python/systemd/connectivity-monitor-archive@.service|.timer` (daily archive/prune of logs/reports) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR implements an always-on operating model for the Python monitor on Raspberry Pi, focused on service resilience and continuous queryability. It adds production-oriented operational controls around
/api/statushealth, data retention, and fast recovery.Service hardening (24/7 uptime)
python/connectivity-monitor@.servicewith restart semantics for long-running operation (Restart=always, shorter backoff), startup ordering onnetwork-online.target, runtime limits/timeouts, and safer service isolation defaults.Scheduled health supervision
python/ops/health_probe.pyto probe/api/status, evaluate degradations (health score / packet loss), persist consecutive-failure state, and optionally trigger reboot after threshold.python/systemd/connectivity-monitor-healthcheck@.service+.timerfor periodic health checks.WEB_PORT).Log/report persistence + retention automation
python/ops/archive_artifacts.pyto archive~/ConnectivityMonitor/logsand~/ConnectivityMonitor/reports, prune old archives, and handle deletion failures explicitly.python/systemd/connectivity-monitor-archive@.service+.timerfor daily archival rotation.Recovery ergonomics
python/ops/recover_service.shas a one-command recovery/verification entrypoint:Operational documentation for production Pi setup
python/README.mdand top-levelREADME.mdwith: