[systemd-devel] Fwd: best way to handle service restarts after hibernate/suspend?

孙冰 subi.the.dream.walker at gmail.com
Thu Aug 8 04:07:38 PDT 2013


Hi,

Yep. I have the exact same sleep at .service and it works.

BTW, sleep.target is pulled in by both suspend.target and
hibernate.target. There are some use cases that a hook should be only
invoked by suspend.target (or hibernate.target). For instance, I have a
hook used with the tuxoniceui:

----------------------------------------------------
[Unit]
Description=tuxoniceui hibernate hook
Before=hibernate.target
StopWhenUnneeded=yes

[Service]
Type=oneshot
RemainAfterExit=yes
ExecStartPre=/bin/bash -c "echo `fgconsole` > %t/tuxoniceui"
ExecStart=/bin/chvt 63
ExecStop=-/bin/bash -c "chvt `< %t/tuxoniceui`"
ExecStopPost=-/bin/rm -rf %t/tuxoniceui

[Install]
WantedBy=hibernate.target

----------------------------------------------------

Obviously I don't want it to be called for suspend.target. The problem
is, by default, suspend.target/hibernate.target is not a
StopWhenUnneeded service. I have to overwrite it in
/etc/systemd/system/hibernate.target.d. It's completely OK for me to do
this. What I wonder is, what is the reason by they are not
StopWhenUnneeded services?

Uh, seems overly off-topic... 

Regards.


More information about the systemd-devel mailing list