<div dir="ltr">Hello<div><br></div><div>  I am pretty new to systemd.</div><div>  I am trying to write two dependent services Myservice and MyserviceTwo.</div><div><br></div><div><b>Myservice.service</b></div><div><br></div>
<div><div><i>[Unit]</i></div><div><i>Description=This is a test service</i></div><div><i><br></i></div><div><i>[Service]</i></div><div><i>PIDFile=/var/run/Myservice.pid</i></div><div><i>ExecStartPre=/bin/rm -f /tmp/log.log</i></div>
<div><i>#ExecStartPre=/usr/bin/systemctl stop Myservice</i></div><div><i>ExecStart=/tmp/one.sh</i></div><div><i>Restart=on-abort</i></div><div><i>NotifyAccess=all</i></div><div><i>WatchdogSec=20</i></div><div><i><br></i></div>
<div><i>[Install]</i></div><div><i>Alias=myservice.services</i></div></div><div><br></div><div><br></div><div><b>MyserviceTwo.service</b></div><div><br></div><div><div><i>[Unit]</i></div><div><i>Description=This is a TWO test service</i></div>
<div><i>Requires=Myservice.service</i></div><div><i>After=Myservice.service</i></div><div><i><br></i></div><div><i>[Service]</i></div><div><i>PIDFile=/var/run/MyserviceTwo.pid</i></div><div><i>#ExecStartPre=/bin/rm -f /tmp/log.log</i></div>
<div><i>ExecStart=/tmp/two.sh</i></div><div><i>Restart=on-abort</i></div><div><i>NotifyAccess=all</i></div><div><i>WatchdogSec=10</i></div><div><i><br></i></div><div><i>[Install]</i></div><div><i>Alias=Salil2.services</i></div>
</div><div><br></div><div><br></div><div>   When I run systemctl start MyserviceTwo, Myservice also gets started. </div><div><br></div><div>   I have put a systemd-notify command in my scripts</div><div><br></div><div><i>systemd-notify WATCHDOG=1 </i><br>
</div><div><i><br></i></div><div>   I deliberately made the one.sh fail so that Myservice will fail.</div><div><br></div><div>   What I expected is - when Myservice fails, MyserviceTwo also fail. But that didn't happen. following is the output of status command</div>
<div><br></div><div><div><i style="background-color:rgb(238,238,238)"><font color="#0000ff">[root@localhost system]# </font><font color="#ff0000"><b>systemctl status Myservice</b></font></i></div><div><i style="background-color:rgb(238,238,238)"><font color="#0000ff">Myservice.service - This is a test service</font></i></div>
<div><i style="background-color:rgb(238,238,238)"><font color="#0000ff">   Loaded: loaded (/usr/lib/systemd/system/Myservice.service; disabled)</font></i></div><div><i style="background-color:rgb(238,238,238)"><font color="#0000ff">   Active: failed (Result: watchdog) since Thu 2013-11-21 00:21:19 IST; 10min ago</font></i></div>
<div><i style="background-color:rgb(238,238,238)"><font color="#0000ff">  Process: 3143 ExecStartPre=/bin/rm -f /tmp/log.log (code=exited, status=0/SUCCESS)</font></i></div><div><i style="background-color:rgb(238,238,238)"><font color="#0000ff"> Main PID: 3145</font></i></div>
<div><i style="background-color:rgb(238,238,238)"><font color="#0000ff">   CGroup: name=systemd:/system/Myservice.service</font></i></div><div><i style="background-color:rgb(238,238,238)"><font color="#0000ff">           ├─3145 /bin/bash /tmp/one.sh</font></i></div>
<div><i style="background-color:rgb(238,238,238)"><font color="#0000ff">           └─4157 sleep 5</font></i></div><div><i style="background-color:rgb(238,238,238)"><font color="#0000ff"><br></font></i></div><div><i style="background-color:rgb(238,238,238)"><font color="#0000ff">Nov 21 00:20:59 localhost.localdomain systemd[1]: Starting This is a test service...</font></i></div>
<div><i style="background-color:rgb(238,238,238)"><font color="#0000ff">Nov 21 00:20:59 localhost.localdomain systemd[1]: Started This is a test service.</font></i></div><div><i style="background-color:rgb(238,238,238)"><font color="#0000ff">Nov 21 00:21:19 localhost.localdomain systemd[1]: Myservice.service watchdog timeout!</font></i></div>
<div><i style="background-color:rgb(238,238,238)"><font color="#0000ff">Nov 21 00:21:19 localhost.localdomain systemd[1]: Unit Myservice.service entered failed state.</font></i></div></div><div><i style="background-color:rgb(238,238,238)"><font color="#0000ff"><br>
</font></i></div><div><i style="background-color:rgb(238,238,238)"><font color="#0000ff">-----</font></i></div><div><i style="background-color:rgb(238,238,238)"><font color="#0000ff"><br></font></i></div><div><div><i style="background-color:rgb(238,238,238)"><font color="#0000ff">[root@localhost system]# </font><b><font color="#ff0000">systemctl status MyserviceTwo</font></b></i></div>
<div><i style="background-color:rgb(238,238,238)"><font color="#0000ff">MyserviceTwo.service - This is a TWO test service</font></i></div><div><i style="background-color:rgb(238,238,238)"><font color="#0000ff">   Loaded: loaded (/usr/lib/systemd/system/MyserviceTwo.service; disabled)</font></i></div>
<div><i style="background-color:rgb(238,238,238)"><font color="#0000ff">   Active: active (running) since Thu 2013-11-21 00:20:59 IST; 11min ago</font></i></div><div><i style="background-color:rgb(238,238,238)"><font color="#0000ff"> Main PID: 3146 (two.sh)</font></i></div>
<div><i style="background-color:rgb(238,238,238)"><font color="#0000ff">   CGroup: name=systemd:/system/MyserviceTwo.service</font></i></div><div><i style="background-color:rgb(238,238,238)"><font color="#0000ff">           ├─3146 /bin/bash /tmp/two.sh</font></i></div>
<div><i style="background-color:rgb(238,238,238)"><font color="#0000ff">           └─4220 sleep 5</font></i></div><div><i style="background-color:rgb(238,238,238)"><font color="#0000ff"><br></font></i></div><div><i style="background-color:rgb(238,238,238)"><font color="#0000ff">Nov 21 00:20:59 localhost.localdomain systemd[1]: Starting This is a TWO test service...</font></i></div>
<div><i style="background-color:rgb(238,238,238)"><font color="#0000ff">Nov 21 00:20:59 localhost.localdomain systemd[1]: Started This is a TWO test service.</font></i></div></div><div><i style="background-color:rgb(238,238,238)"><font color="#0000ff"><br>
</font></i></div><div><font style="background-color:rgb(255,255,255)" color="#000000">Any pointers on how to debug the issue </font></div><div><font style="background-color:rgb(255,255,255)" color="#000000"><br></font></div>
<div><font style="background-color:rgb(255,255,255)" color="#000000">Thanks</font></div><div><font style="background-color:rgb(255,255,255)" color="#000000">~S</font></div></div>