[systemd-devel] Starting a unit on resume from suspend/hibernate
Andrei Borzenkov
arvidjaar at gmail.com
Thu Apr 2 10:51:04 PDT 2015
В Thu, 2 Apr 2015 19:34:55 +0200 (CEST)
Dimitrios Apostolou <jimis at gmx.net> пишет:
> On Thu, 2 Apr 2015, Dimitrios Apostolou wrote:
>
> > On Thu, 2 Apr 2015, Andrei Borzenkov wrote:
> >
> >> В Thu, 2 Apr 2015 18:43:40 +0200 (CEST)
> >> Dimitrios Apostolou <jimis at gmx.net> пишет:
> >>
> >> > Conflicts=sleep.target
> >> > WantedBy=multi-user.target sleep.target
> >>
> >> These are mutually conflicting. One one hand Conflicts says to stop your
> >> unit when sleep.target gets started, on the other hand WantedBy says to
> >> start your unit when sleep.target gets started. Only one can win.
> >
> > Indeed, but I was assuming that combined with "after" they could co-exist,
> > starting the unit after the dependency has started and stopped. And if it was
> > a problem I would expect a message, since it's easy to detect.
> >
> > Anyway even removing the Conflicts line does not help. "systemctl enable"
> > still does not install the symlink, and manually installing the symlink does
> > not change anything.
>
> Hmmm I did some more trials with the "conflicts" line commented out. While
> just listing "sleep.target" didn't work, the following was successful and
> the unit starts after resuming:
>
How is it stopped then? It is apparently started on boot (WantedBy
multi-user.target) and there is no conflicts so it is never stopped.
> After=sleep.target suspend.target hibernate.target hybrid-sleep.target
Yes, this works due to the way it is implemented. Not sure if it is
committed functionality though.
> WantedBy=multi-user.target sleep.target suspend.target hibernate.target hybrid-sleep.target
>
This is redundant, WantedBy=sleep.target should be enough.
> In addition "systemctl disable/enable" didn't create the symlinks, I had
> to properly add them. Maybe it's a bug?
bor at opensuse:~/src/dmraid/1.0.0.rc16-3/dmraid> systemctl status test.servicetest.service - Test
Loaded: loaded (/run/systemd/system/test.service; disabled)
Active: inactive (dead)
bor at opensuse:~/src/dmraid/1.0.0.rc16-3/dmraid> sudo systemctl enable test.service
bor at opensuse:~/src/dmraid/1.0.0.rc16-3/dmraid> systemctl status test.servicetest.service - Test
Loaded: loaded (/run/systemd/system/test.service; enabled)
Active: inactive (dead)
bor at opensuse:~/src/dmraid/1.0.0.rc16-3/dmraid> ll /etc/systemd/system/sleep.target.wants/
итого 0
lrwxrwxrwx 1 root root 32 апр 2 20:36 test.service -> /run/systemd/system/test.service
bor at opensuse:~/src/dmraid/1.0.0.rc16-3/dmraid>
>
>
> Thanks,
> Dimitris
More information about the systemd-devel
mailing list