Skip to content

Module side of the systemd mode: READY=1, no duplicate journal lines, pyobsd exec - #1106

Merged
thusser merged 1 commit into
developfrom
feat/systemd-module-side
Nov 25, 2026
Merged

thusser merged 1 commit into
developfrom
feat/systemd-module-side

Conversation

@thusser

@thusser thusser commented Nov 25, 2026

Copy link
Copy Markdown
Member

Second step of the pyobsd systemd mode (specs/plans/2026-11-25-pyobsd-systemd-mode.md). Everything here is a no-op outside systemd, so it can be released before the systemd backend lands.

Changes

  • READY=1: Application._main() sends READY=1 right after startup(), before main(). shutdown.notify does nothing without $NOTIFY_SOCKET. If startup() fails, nothing is sent.
  • No duplicate journal lines: with --syslog, no stderr StreamHandler when stderr is the journal. _stderr_is_journal() compares $JOURNAL_STREAM with stderr's device and inode (systemd.exec(5)), because child processes inherit the variable even when their stderr goes elsewhere. Output written straight to stderr (tracebacks, C libraries) still reaches the journal.
  • pyobsd exec <module>: internal and hidden from --help. It looks up <module>.yaml, then _<module>.yaml, and execs pyobs in the foreground with the options from the pyobsd config, without --pid-file. It works in both modes and doesn't use chuid. The argument building (_pyobs_args) is shared with the PID-file backend, and the arguments that backend passes are unchanged.

Tests

  • New: tests/test_application_systemd.py and tests/cli/test_pyobsd_exec.py.
  • Full suite without integration/xmpp: 2821 passed.
  • ruff and black are clean.

Open for the next PR

Application exits with code 0 even after a caught exception in startup()/main(), so with Restart=on-failure a crashed module would not be restarted. That gets decided together with the unit.

🤖 Generated with Claude Code

… pyobsd exec

- Application sends READY=1 once the module is open (no-op without
  $NOTIFY_SOCKET).
- With --syslog, no stderr handler if stderr is the journal ($JOURNAL_STREAM
  compared with stderr's device and inode, since children inherit it).
- pyobsd exec <module> (hidden): finds <module>.yaml or _<module>.yaml and
  execs pyobs in the foreground with the options from the pyobsd config,
  without --pid-file. Argument building is shared with the PID-file mode.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@thusser
thusser merged commit 3f74a16 into develop Nov 25, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant