[systemd-devel] Newbie question - Requires doesn't work properly
Zbigniew Jędrzejewski-Szmek
zbyszek at in.waw.pl
Wed Nov 20 05:54:30 PST 2013
On Wed, Nov 20, 2013 at 07:09:13PM +0530, salil GK wrote:
> 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*
That's not nice.
> *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
Requires= is only relevant at service start time. I think BindsTo=
should work for you.
Zbyszek
More information about the systemd-devel
mailing list