Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Correct support for systemd-sleep #40

Merged
merged 1 commit into from
Dec 9, 2024

Conversation

ciphorg
Copy link

@ciphorg ciphorg commented Dec 9, 2024

Background

I noticed the service declared [Unit] After=multi-user.target and would fail to restart following a systemd-sleep events. The service correctly starts on a fresh boot, but would not be triggered by a sleep.target trigger (suspend, hibernate, hybrid, etc...).

The service should only start after a successful boot (at-least multi-user.target), but still requires a dependency trigger on sleep.target to restart on wake.


[Install] WantedBy= ... has the effect of a dependency of type Wants=, Requires=, or Upholds= being added from the listed unit to the current unit. [1]
Additionally, multi-user.target is triggered after poweroff.target & rescue.target, but not triggered again after sleep.target [2] [3]


Changes

Full support for restarting after systemd-sleep should just require After=sleep.target added to the service's [Unit] section. This change should safely and reliably request OpenLinkHub to resume after sleep.target without effecting systemd's critical chain. This should avoid having to be overly complex in handling the boot->sleep->wake->shutdown cycle, and for systemd to "want" the service to start on boot (not require it) and to also restart the service after resuming from any sleep state.

[Unit]
After=sleep.target

[Service]
...

[Install]
WantedBy=multi-user.target

@jurkovic-nikola jurkovic-nikola merged commit 5367f02 into jurkovic-nikola:main Dec 9, 2024
1 check 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.

2 participants