[systemd-devel] Newbie question - Requires doesn't work properly
salil GK
gksalil at gmail.com
Wed Nov 20 05:39:13 PST 2013
Hello
I am pretty new to systemd.
I am trying to write two dependent services Myservice and MyserviceTwo.
*Myservice.service*
*[Unit]*
*Description=This is a test service*
*[Service]*
*PIDFile=/var/run/Myservice.pid*
*ExecStartPre=/bin/rm -f /tmp/log.log*
*#ExecStartPre=/usr/bin/systemctl stop Myservice*
*ExecStart=/tmp/one.sh*
*Restart=on-abort*
*NotifyAccess=all*
*WatchdogSec=20*
*[Install]*
*Alias=myservice.services*
*MyserviceTwo.service*
*[Unit]*
*Description=This is a TWO test service*
*Requires=Myservice.service*
*After=Myservice.service*
*[Service]*
*PIDFile=/var/run/MyserviceTwo.pid*
*#ExecStartPre=/bin/rm -f /tmp/log.log*
*ExecStart=/tmp/two.sh*
*Restart=on-abort*
*NotifyAccess=all*
*WatchdogSec=10*
*[Install]*
*Alias=Salil2.services*
When I run systemctl start MyserviceTwo, Myservice also gets started.
I have put a systemd-notify command in my scripts
*systemd-notify WATCHDOG=1 *
I deliberately made the one.sh fail so that Myservice will fail.
What I expected is - when Myservice fails, MyserviceTwo also fail. But
that didn't happen. following is the output of status command
*[root at localhost system]# systemctl status Myservice*
*Myservice.service - This is a test service*
* Loaded: loaded (/usr/lib/systemd/system/Myservice.service; disabled)*
* Active: failed (Result: watchdog) since Thu 2013-11-21 00:21:19 IST;
10min ago*
* Process: 3143 ExecStartPre=/bin/rm -f /tmp/log.log (code=exited,
status=0/SUCCESS)*
* Main PID: 3145*
* CGroup: name=systemd:/system/Myservice.service*
* ├─3145 /bin/bash /tmp/one.sh*
* └─4157 sleep 5*
*Nov 21 00:20:59 localhost.localdomain systemd[1]: Starting This is a test
service...*
*Nov 21 00:20:59 localhost.localdomain systemd[1]: Started This is a test
service.*
*Nov 21 00:21:19 localhost.localdomain systemd[1]: Myservice.service
watchdog timeout!*
*Nov 21 00:21:19 localhost.localdomain systemd[1]: Unit Myservice.service
entered failed state.*
*-----*
*[root at localhost system]# systemctl status MyserviceTwo*
*MyserviceTwo.service - This is a TWO test service*
* Loaded: loaded (/usr/lib/systemd/system/MyserviceTwo.service; disabled)*
* Active: active (running) since Thu 2013-11-21 00:20:59 IST; 11min ago*
* Main PID: 3146 (two.sh)*
* CGroup: name=systemd:/system/MyserviceTwo.service*
* ├─3146 /bin/bash /tmp/two.sh*
* └─4220 sleep 5*
*Nov 21 00:20:59 localhost.localdomain systemd[1]: Starting This is a TWO
test service...*
*Nov 21 00:20:59 localhost.localdomain systemd[1]: Started This is a TWO
test service.*
Any pointers on how to debug the issue
Thanks
~S
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/systemd-devel/attachments/20131120/5a2375a7/attachment.html>
More information about the systemd-devel
mailing list