feat: Add scheduled runs and Kuma ping
Add systemd user units for daily execution and send an Uptime Kuma push on each run.
This commit is contained in:
parent
4ab799c156
commit
413766ed2b
6 changed files with 67 additions and 0 deletions
|
|
@ -12,3 +12,6 @@ FRESHRSS_PASSWORD=your-password
|
||||||
MATRIX_HOMESERVER=https://matrix.example.net
|
MATRIX_HOMESERVER=https://matrix.example.net
|
||||||
MATRIX_ROOM_ID=!roomid:example.net
|
MATRIX_ROOM_ID=!roomid:example.net
|
||||||
MATRIX_ACCESS_TOKEN=replace-with-access-token
|
MATRIX_ACCESS_TOKEN=replace-with-access-token
|
||||||
|
|
||||||
|
# Uptime Kuma push URL
|
||||||
|
UPTIME_KUMA_PUSH_URL=https://uptime.example.net/api/push/your-token
|
||||||
|
|
|
||||||
18
BACKLOG.md
18
BACKLOG.md
|
|
@ -134,3 +134,21 @@ Acceptance criteria:
|
||||||
- The script posts a message to a Matrix room when updates are detected or errors occur.
|
- The script posts a message to a Matrix room when updates are detected or errors occur.
|
||||||
- Matrix credentials (homeserver, room id, access token) are read from `.env`.
|
- Matrix credentials (homeserver, room id, access token) are read from `.env`.
|
||||||
- The message includes actionable service names and version details.
|
- The message includes actionable service names and version details.
|
||||||
|
|
||||||
|
## US-15 - Systemd User Service
|
||||||
|
|
||||||
|
As a maintainer, I want a systemd user service and timer so the script runs daily without manual intervention.
|
||||||
|
|
||||||
|
Acceptance criteria:
|
||||||
|
- Provide a user-level systemd service file that runs the update checker.
|
||||||
|
- Provide a user-level timer that runs once per day.
|
||||||
|
- README documents how to install and enable the service and timer.
|
||||||
|
|
||||||
|
## US-16 - Uptime Kuma Push
|
||||||
|
|
||||||
|
As a maintainer, I want the script to call an Uptime Kuma push URL on each run so that failures are visible in the monitoring dashboard.
|
||||||
|
|
||||||
|
Acceptance criteria:
|
||||||
|
- The script sends a request to the push URL when it runs.
|
||||||
|
- The push URL is configured via `.env`.
|
||||||
|
- Failures to reach the push URL are logged without crashing the run.
|
||||||
|
|
|
||||||
19
README.md
19
README.md
|
|
@ -25,6 +25,7 @@ export FRESHRSS_PASSWORD=...
|
||||||
export MATRIX_HOMESERVER=...
|
export MATRIX_HOMESERVER=...
|
||||||
export MATRIX_ROOM_ID=...
|
export MATRIX_ROOM_ID=...
|
||||||
export MATRIX_ACCESS_TOKEN=...
|
export MATRIX_ACCESS_TOKEN=...
|
||||||
|
export UPTIME_KUMA_PUSH_URL=...
|
||||||
```
|
```
|
||||||
|
|
||||||
The script also reads `.env` automatically if present.
|
The script also reads `.env` automatically if present.
|
||||||
|
|
@ -49,3 +50,21 @@ To run live integration checks against the real services:
|
||||||
```bash
|
```bash
|
||||||
RUN_LIVE_TESTS=1 python -m pytest tests/test_live_services.py
|
RUN_LIVE_TESTS=1 python -m pytest tests/test_live_services.py
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## Systemd (user)
|
||||||
|
|
||||||
|
Copy the unit files and enable the timer:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
mkdir -p ~/.config/systemd/user
|
||||||
|
cp systemd/check-for-updates.service ~/.config/systemd/user/
|
||||||
|
cp systemd/check-for-updates.timer ~/.config/systemd/user/
|
||||||
|
systemctl --user daemon-reload
|
||||||
|
systemctl --user enable --now check-for-updates.timer
|
||||||
|
```
|
||||||
|
|
||||||
|
View logs:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
journalctl --user -u check-for-updates.service
|
||||||
|
```
|
||||||
|
|
|
||||||
|
|
@ -565,6 +565,16 @@ def join_matrix_room(homeserver: str, room_id: str, token: str, timeout: float)
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|
||||||
|
def send_uptime_kuma_ping(timeout: float) -> None:
|
||||||
|
push_url = os.getenv("UPTIME_KUMA_PUSH_URL")
|
||||||
|
if not push_url:
|
||||||
|
return
|
||||||
|
try:
|
||||||
|
fetch_response(push_url, timeout=timeout, user_agent="check-for-updates")
|
||||||
|
except Exception as exc:
|
||||||
|
print(f"Uptime Kuma push failed: {exc}", file=sys.stderr)
|
||||||
|
|
||||||
|
|
||||||
def main() -> int:
|
def main() -> int:
|
||||||
parser = argparse.ArgumentParser(description="Check for webservice updates")
|
parser = argparse.ArgumentParser(description="Check for webservice updates")
|
||||||
parser.add_argument("--config", default="services.yaml", help="Path to services YAML")
|
parser.add_argument("--config", default="services.yaml", help="Path to services YAML")
|
||||||
|
|
@ -622,6 +632,7 @@ def main() -> int:
|
||||||
summary, should_notify = build_summary(results)
|
summary, should_notify = build_summary(results)
|
||||||
if should_notify:
|
if should_notify:
|
||||||
send_matrix_message(summary, args.timeout)
|
send_matrix_message(summary, args.timeout)
|
||||||
|
send_uptime_kuma_ping(args.timeout)
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
7
systemd/check-for-updates.service
Normal file
7
systemd/check-for-updates.service
Normal file
|
|
@ -0,0 +1,7 @@
|
||||||
|
[Unit]
|
||||||
|
Description=Check hosted services for updates
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
Type=oneshot
|
||||||
|
WorkingDirectory=%h/Projects/check-for-updates
|
||||||
|
ExecStart=%h/Projects/check-for-updates/.venv/bin/python %h/Projects/check-for-updates/check_updates.py --config %h/Projects/check-for-updates/services.yaml
|
||||||
9
systemd/check-for-updates.timer
Normal file
9
systemd/check-for-updates.timer
Normal file
|
|
@ -0,0 +1,9 @@
|
||||||
|
[Unit]
|
||||||
|
Description=Run update checks daily
|
||||||
|
|
||||||
|
[Timer]
|
||||||
|
OnCalendar=daily
|
||||||
|
Persistent=true
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=timers.target
|
||||||
Loading…
Add table
Add a link
Reference in a new issue