secubox-deb/packages/secubox-peertube/api
CyberMind 4a6b853785
fix(peertube): drain admin-ops results to a separate dir (fixes start-limit loop, #798) (#804)
* fix(peertube): drain admin-ops results to a separate dir (fixes start-limit loop, ref #798)

The root peertube-ops.path watches OPS_DIR with DirectoryNotEmpty=. process-ops
wrote each <id>.result.json back into OPS_DIR, so the directory was never empty
after draining a request → the .path re-triggered peertube-ops.service in a tight
loop until systemd killed it with start-limit-hit, after which the mechanism died
after the first op.

Write results to a dedicated /run/secubox/peertube/results/ instead; process-ops
rm's the request, leaving OPS_DIR empty so the watcher goes idle. The API's
_read_op_result now polls RESULTS_DIR. tmpfiles + postinst create the dir
(0750 secubox:secubox); peertubectl honors SECUBOX_PEERTUBE_RESULTS_DIR.

test_process_ops.sh asserts results land in results/ and OPS_DIR is empty after
draining (regression guard); test_ops_api monkeypatches both dirs.

Verified live on gk2: two consecutive pings drain cleanly, NRestarts=0, no
start-limit-hit, results root:secubox 0640 (secubox-readable).

* fix(peertube): upgrade CWD must be peertube-latest/scripts + surface the error (ref #798)

The webui upgrade button failed with a generic "upgrade script failed" and no detail.
Two bugs in cmd_upgrade:

1. Wrong CWD. PeerTube's v8 shim peertube-latest/scripts/upgrade.sh execs
   `../dist/scripts/upgrade.sh` relative to CWD, and that dist script runs
   `node -e "require('js-yaml')…"` whose resolution is also CWD-relative. Running from
   `cd /var/www/peertube` made `../dist` → /var/www/dist (missing) → "cannot open
   ../dist/scripts/upgrade.sh"; a neutral CWD instead fails "Cannot find module
   'js-yaml'". Fix: cd /var/www/peertube/peertube-latest/scripts (../dist resolves,
   and require() walks up to peertube-latest/node_modules).

2. Error was discarded to /dev/null, so the result only said "upgrade script failed".
   Now capture to /run/secubox/peertube/upgrade-<id>.log and fold the last lines into
   the error detail.

Verified live: with the corrected CWD, 8.2.0 → 8.2.2 upgraded cleanly (download + deps
+ migrations), service restarted, /api/v1/config 200, serverVersion 8.2.2.

---------

Co-authored-by: CyberMind-FR <gandalf@Gk2.net>
2026-07-04 18:15:21 +02:00
..
routers feat(phase8): Complete all 21 Application modules 2026-04-04 10:04:25 +02:00
__init__.py feat(phase8): Complete all 21 Application modules 2026-04-04 10:04:25 +02:00
main.py fix(peertube): drain admin-ops results to a separate dir (fixes start-limit loop, #798) (#804) 2026-07-04 18:15:21 +02:00