Skip to content

Protect live and carried streams from planned shutdown - #85

Draft
pjeweb wants to merge 3 commits into
osb/pr/carrying-livenessfrom
feat/shutdown-inhibitor
Draft

pjeweb wants to merge 3 commits into
osb/pr/carrying-livenessfrom
feat/shutdown-inhibitor

Conversation

@pjeweb

@pjeweb pjeweb commented Nov 14, 2026 •

Copy link
Copy Markdown

Why

A routine restart, from the UI, an update or a scheduled shutdown, can cut a live stream or a phone's traffic going through the box without warning. The box should refuse a planned shutdown while it is actually streaming, and say why. At the same time, there has to be a clear way out in an emergency, and a stuck system bus must never freeze the interface.

What

  • While the box streams or carries a phone's traffic, it holds a shutdown lock, so a planned restart or power off is refused.
  • The refusal is translated and says what to do; after a lock refusal it also shows the emergency override: as root, systemctl stop ceralive, then systemctl reboot.
  • An idle box stays rebootable even while someone is connected over SSH for support.
  • Boot and the interface stay responsive while the lock is being taken, even if the system bus doesn't answer.

How: CeraUI asks logind, the system service that handles shutdown requests, for an inhibitor lock and keeps the file descriptor it returns; the kernel releases it if CeraUI exits. The request runs without blocking, with a 200 ms deadline and a one-second back-off after a failure, and a stream only starts once protection is confirmed. The main loop now also sends the systemd watchdog ping, so a hung backend is restarted instead of holding the lock forever.

Sits on #69 (merged). The companion image change, openstreambox/image-building-pipeline#38, makes safety power-key presses win over shutdown locks.

How to verify

With mock data, the power dialog shows each refusal reason, and the emergency override after a lock refusal. On a box with a stream running, systemctl reboot as root is refused until systemctl stop ceralive has run. apps/backend/src/tests/logind-stall.test.ts checks that a silent bus doesn't block the event loop or the watchdog.

Testing and limits
  • Backend, frontend, rpc, i18n and sender suites pass, along with lint, type checks and the production build. The browser refusal cases pass at 390 and 1280 px.
  • Against real systemd 257 without polkit: root is refused while locked, the override works, and with logind or dbus stopped the backend still becomes ready within two seconds and stays up with no restarts.
  • Plain reboot, scheduled shutdown and -i don't bypass this lock on the image; direct target activation and forced reboot are outside the supported procedure.
  • The lock doesn't help while the backend itself is down, against watchdog or kernel resets, or against power loss.
  • Not tried on hardware yet.
Screenshots

Mock data, desktop 1280 px and mobile 390 px.

State Before After
Idle power dialog · 390 px Before mobile dialog After mobile dialog
Refused restart · 390 px Before mobile refusal After mobile refusal
Idle power dialog · 1280 px Before desktop dialog After desktop dialog
Refused restart · 1280 px Before desktop refusal After desktop refusal

Risks

Someone who really needs to restart mid-stream now has to stop the stream first or use the root override. If logind misbehaves, the lock can't be taken and the stream won't start; the deadline and retry are there to keep that short.


Checklist

  • Docs updated if behavior or structure changed (Rule A: AGENTS.md within budget, README, docs/, versions.yaml)
  • User docs (Rule G): no user-visible change, OR ceralive-docs PR updates English and Spanish, plus ceralive-website PR if a landing claim changed
  • Started from updated main; branch rebased on latest canonical branch (Rule B)
  • Rule D local-scratch reference check passes for tracked files
  • Tests pass; QA evidence attached or linked

@pjeweb pjeweb added stacked Depends on another pull request; review and integrate parents first. upstream: waits for intent Needs an issue or maintainer agreement before an upstream proposal. labels Nov 16, 2026
@pjeweb pjeweb added the train: image-5 In the integration that ships in image 5; the label moves on when images advance. label Nov 21, 2026
@pjeweb pjeweb added train: image-6 In the integration that ships in image 6; the label moves on when images advance. and removed train: image-5 In the integration that ships in image 5; the label moves on when images advance. labels Nov 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

stacked Depends on another pull request; review and integrate parents first. train: image-6 In the integration that ships in image 6; the label moves on when images advance. upstream: waits for intent Needs an issue or maintainer agreement before an upstream proposal.

Development

Successfully merging this pull request may close these issues.

1 participant