Skip to content

Conversation

@joggee-fr
Copy link
Collaborator

When enabled, the feature uses libsystemd to notify service manager about the following states:

  • ready
  • periodic alive ping (20s)
  • stopping

It allows to use Cage in a systemd unit with following options:

Type=notify
WatchdogSec=30s

When enabled, the feature uses libsystemd to notify service manager
about the following states:
- ready
- periodic alive ping (20s)
- stopping

It allows to use Cage in a systemd unit with following options:
Type=notify
WatchdogSec=30s
@emersion
Copy link
Member

In general I don't really like adding systemd-specific logic to software.

@joggee-fr
Copy link
Collaborator Author

joggee-fr commented Sep 11, 2025

I understand, however it looks to me that is the more efficient way for Cage to be integrated as a systemd service unit.

The main case I encountered is, in an embedded Linux custom distribution, start the main graphical application when the Wayland composer is ready. It avoids temporary failures because of not yet existing Wayland socket. And the application is expected to run with its own user, not as the cage user. Starting it as a dedicated systemd service unit offers also several interesting settings.

So with these modifications, the application service unit can use efficiently the description below as we know the Wayland socket will be ready when starting.

[Unit]
Description=Main application
Requires=cage.service
After=cage.service
[...]

Of course, there are, like always, plenty of other solutions but I didn't find one as easy as to integrate systemd logic in Cage itself.
For example, for the case described above, we can rely on a systemd path unit waiting for /run/user/<uid>/wayland-0.
Or run a script as Cage client notifying ready status without forgetting to play with at least NotifyAccess setting.

For information, on its side, Weston composer uses a dedicated plugin named systemd-notify to do the job:

One last point, integrating systemd in Cage (with a tiny abstraction) allows to add ping to software watchdog directly in the main loop. Using the same abstraction, we certainly could support later other process supervisor.

@emersion
Copy link
Member

emersion commented Sep 11, 2025

start the main graphical application when the Wayland composer is ready

Would socket activation be more appropriate here?

See swaywm/sway#8259

Weston composer uses a dedicated plugin named systemd-notify to do the job

FWIW, it should be possible to exec systemd-notify from cage's startup script.

@joggee-fr joggee-fr marked this pull request as draft September 12, 2025 09:34
@joggee-fr
Copy link
Collaborator Author

Would socket activation be more appropriate here?

I made some tests and could be a reliable solution to manage dependencies.

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.

2 participants