wrolpi/etc/raspberrypios
lrnselfreliance 811793d767
perpetual: clear in-progress flags after a crash, downloads only in the perpetual process, KillMode=mixed (#726)
* perpetual: clear in-progress flags after a crash; downloads only in the perpetual process

Found by a kill -9 stress test on a device:

A SIGKILL inside `with flags.file_worker_counting` (or any of the file
worker's progress flags) left the shared flag set, so every later refresh
raised "flag is already set" until the whole API was restarted.
reconcile_after_predecessor now clears the perpetual process's in-progress
flags (file_worker_*, global_refresh_active) and reports it.

create_downloads started a dispatch in whatever process called it, so an
API worker executed downloads (and could take transcode_lock) despite the
single-process design.  It now dispatches only inside the perpetual
process (or under pytest); the download loop picks new rows up within
seconds otherwise.

The shared restart cooldown drops from 60 s to 15 s: it only has to
outlast the manager acting on a request, and a replacement that dies
right away was left dead for the rest of the minute.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>

* systemd: KillMode=mixed for the API so main shuts its own children down

With control-group kill, SIGTERM reaches the multiprocessing Manager at
the same moment as Sanic's main process; main's cleanup then writes
worker state to a dead Manager (broken pipe) and exits 1, so a plain
`systemctl stop` is recorded as a failure whenever a child takes a
moment to stop (a transcode being killed, for instance).  Signal only
main; it stops the workers and the perpetual process itself.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>

* perpetual: clear an in-progress flag only when its holder is dead

`with flag:` now records the holder pid in shared_ctx.flag_holders and
drops it on exit.  The reconcile step clears the flags only the perpetual
process ever enters (file_worker_counting, file_worker_discovery,
global_refresh_active) whenever they are set, and the flags API workers
also enter (file_worker_modeling / indexing / cleanup via refresh_sync,
map_search_building via the map rebuild endpoints) only when the
recorded holder is dead.  file_worker_busy is no longer touched: a
collection move in an API worker holds it as a mutex, and
process_queue drops a stale one itself.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>

---------

Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
2026-09-26 11:22:58 -06:00
..
motd Updating MOTD to suggest ip addresses on login. 2025-08-18 11:33:44 -06:00
50x.html Debian 13 (trixie) rebase: docker, debian-live-config, and pi-gen builds. 2026-07-13 15:43:08 -06:00
90-wrolpi Debian 13 (trixie) rebase: docker, debian-live-config, and pi-gen builds. 2026-07-13 15:43:08 -06:00
Caddyfile Speed Test calculator: ping, download, and upload against the API (#708) 2026-09-13 18:47:18 -06:00
Caddyfile.onboarding Migrating Controller from port 8087 to 80 so that it is more discoverable. Reformatting Controller dashboard to make header at the top. Reformatting navigation bar to handle the new links which prevented Admin from being visible in some screens. 2026-04-09 15:01:05 -06:00
controller-logo.png Creating WROLPi Controller desktop icon. 2026-02-14 17:05:57 -07:00
controller.desktop Migrating Controller from port 8087 to 80 so that it is more discoverable. Reformatting Controller dashboard to make header at the top. Reformatting navigation bar to handle the new links which prevented Admin from being visible in some screens. 2026-04-09 15:01:05 -06:00
gnome-disks.desktop Migrating Controller from port 8087 to 80 so that it is more discoverable. Reformatting Controller dashboard to make header at the top. Reformatting navigation bar to handle the new links which prevented Admin from being visible in some screens. 2026-04-09 15:01:05 -06:00
wrolpi-api-dev.service perpetual: clear in-progress flags after a crash, downloads only in the perpetual process, KillMode=mixed (#726) 2026-09-26 11:22:58 -06:00
wrolpi-api.service perpetual: clear in-progress flags after a crash, downloads only in the perpetual process, KillMode=mixed (#726) 2026-09-26 11:22:58 -06:00
wrolpi-app-dev.service Adding wrolpi-app-dev which runs frontend in dev mode. 2025-12-18 18:01:45 -07:00
wrolpi-app.service install: always install serve; resolve it via PATH in wrolpi-app 2026-07-23 18:21:58 -06:00
wrolpi-cert-renew.service Replace nginx with Caddy for TLS termination and reverse proxying. 2026-03-07 18:48:44 -07:00
wrolpi-cert-renew.timer Replace nginx with Caddy for TLS termination and reverse proxying. 2026-03-07 18:48:44 -07:00
wrolpi-controller.service Postgres -> SQLite hard cutover: the database moves into the media directory. 2026-07-12 14:09:37 -06:00
wrolpi-first-startup.service Creating script which runs on first startup only. This is used to copy /etc/skel files to first user's home directory. 2024-06-18 16:17:54 -06:00
wrolpi-fix-media-permissions.service Creating script that fixes media directory file and directory permissions, adding it to the Controller UI. 2026-03-05 17:58:21 -07:00
wrolpi-help-files.desktop Moving HTTP kiwix/help services to 9085/9086 ports. Nginx will serve HTTPS proxy for kiwix/help services at the old ports. Modifying apache2 to use HTTPS to serve map. 2024-06-12 21:38:51 -06:00
wrolpi-help-script.service Controller: add help.sh to the Maintenance Scripts. 2026-07-09 16:00:43 -06:00
wrolpi-help.desktop A directory containing files that have been tagged is maintained automatically by WROLPi. 2024-10-16 18:56:05 -06:00
wrolpi-help.service Modifying niceness of WROLPi services to facilitate API startup. 2025-03-03 19:28:35 -07:00
wrolpi-kiwix.service kiwix: a corrupt zim must not bring down the whole server 2026-07-20 13:06:46 -06:00
wrolpi-mounts.service Merging wrolpi-portable into debian-live-config; unifying Postgres on /media/wrolpi/config/postgresql. 2026-05-24 12:44:05 -06:00
wrolpi-repair.service Enhancing Controller to run scripts, starting with the repair and upgrade scripts for onboarding use. 2026-02-25 17:08:32 -07:00
wrolpi-upgrade.service upgrade.sh delegates to wrolpi-upgrade service so that logs are visible in controller, even if launched from terminal. 2026-02-03 16:42:06 -07:00
wrolpi.desktop Moving HTTP kiwix/help services to 9085/9086 ports. Nginx will serve HTTPS proxy for kiwix/help services at the old ports. Modifying apache2 to use HTTPS to serve map. 2024-06-12 21:38:51 -06:00
wrolpi.target Postgres -> SQLite hard cutover: the database moves into the media directory. 2026-07-12 14:09:37 -06:00