I have a service defined as bellow:
Unit]
Description=My Service
After=network.target
[Service]
ExecStart=/usr/local/bin/myservice
KillMode=process
Restart=on-failure
ExecStartPost=/usr/local/bin/script.sh
[Install]
WantedBy=multi-user.target
and script.sh
contains commands like:
while ! $(systemctl is-active --quiet myservice) ; do echo "waiting.."; sleep 5; done
(and other calls to the service)
The problem is that it doesn't work. I think it's a chicken-and-egg issue. I'm waiting for the service to be up in the service start itself. This obviously can't work.
So my question is:
How can I run script.sh
automatically when myservice is up?
Thanks