Files
MichilisandClaude Fable 5.2 7d4893bc3f Phase 4: scale out
Remote workers, Postgres and S3, all chosen by configuration.

- Pull-based worker protocol over HTTP: claim (long poll), heartbeat,
  complete, fail, upload, source, probe. Workers need no inbound ports
- cmd/worker: standalone stateless worker with health endpoint and
  scheduled yt-dlp self-update
- Per-worker bearer tokens, stored hashed, revocable; identity always
  taken from the token; actions only on jobs the worker holds a lease for
- Tags: site_tags routes a site's jobs and lookups to workers that carry
  the required tags
- Drain, /workers, /ytdlp update, and "core worker add|revoke|list"
- Link lookups can run on remote workers (PROBE_MODE), so the core needs
  no yt-dlp and no residential address
- Postgres backend with pgx, same schema and queries; per-user advisory
  lock and job row lock where SQLite's serial writes were relied on
- The whole test suite runs on SQLite and on Postgres
- S3 storage backend with presigned worker uploads, sharing a conformance
  suite with the local backend
- Dockerfile with core, worker and faketelegram targets, docker-compose
  with optional Postgres and local Bot API server, systemd units
- deploy/acceptance/kill-worker.sh: kills a worker mid-job and checks
  that the other one delivers the file
- Fixes found on the way: /cancel could let the next playlist item start;
  a refund note could be missing when the sweep refunded first

Docker was not available on the build machine: the compose files were
validated with "docker compose config" only. The acceptance scenario was
run with real processes.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-18 09:27:11 +00:00

52 lines
1.6 KiB
Desktop File

# The Noderunners Download Bot: download worker.
#
# A worker needs outbound access to the core and to the sites it downloads
# from. It needs no inbound port and no secrets other than its own token.
#
# install -m 0755 bin/worker /usr/local/bin/dlbot-worker
# useradd --system --home-dir /var/lib/dlbot-worker --create-home dlbot
# install -d -m 0750 -o dlbot -g dlbot /etc/dlbot
# printf 'CORE_URL=https://bot.example.com\nWORKER_TOKEN=dlw_...\nWORKER_TEMP_DIR=/var/lib/dlbot-worker/tmp\n' \
# > /etc/dlbot/worker.env && chmod 0640 /etc/dlbot/worker.env && chown dlbot:dlbot /etc/dlbot/worker.env
# systemctl enable --now dlbot-worker
#
# yt-dlp updates itself, so install it somewhere the service user can
# write, for example /var/lib/dlbot-worker/bin/yt-dlp, and set YTDLP_PATH.
# To run several workers on one machine, copy this unit and give each its
# own token and its own WORKER_TEMP_DIR.
[Unit]
Description=The Noderunners Download Bot (worker)
Documentation=https://github.com/noderunners/dlbot
After=network-online.target
Wants=network-online.target
[Service]
Type=simple
User=dlbot
Group=dlbot
WorkingDirectory=/var/lib/dlbot-worker
EnvironmentFile=/etc/dlbot/worker.env
ExecStart=/usr/local/bin/dlbot-worker
Restart=on-failure
RestartSec=5
# On SIGTERM the worker stops its downloads and hands the jobs back.
TimeoutStopSec=30
KillSignal=SIGTERM
NoNewPrivileges=true
ProtectSystem=strict
ProtectHome=true
PrivateTmp=true
PrivateDevices=true
ProtectKernelTunables=true
ProtectKernelModules=true
ProtectControlGroups=true
RestrictSUIDSGID=true
LockPersonality=true
ReadWritePaths=/var/lib/dlbot-worker
UMask=0027
[Install]
WantedBy=multi-user.target