[systemd-devel] systemd-run and waiting for initialization

Igor Bukanov igor at mir2.org
Mon Mar 30 22:50:16 PDT 2015

It would be really nice to have an utility that waits until a unit is
transitioned from the activating state. My problem is that I wanted to
replace in a shell script a sequence like:

sudo -u some_user ssh -f port_forwarding host
kill hopefully rightly guessed ssh PID

with something like

sudo systemd-run --uid user --service-type=forking ...  ssh -f
port_forwarding host
sudo systemctl stop unit_name

as that is easier to make reliable. However, this does not work as I
expected as systemd-run does not wait for the ssh -f unit to transition
from the activating state indicating that port forwarding is established.
So I need to implement own wait or polling.

On 31 March 2015 at 05:51, Andrei Borzenkov <arvidjaar at gmail.com> wrote:

> В Mon, 30 Mar 2015 09:48:25 +0200
> Igor Bukanov <igor at mir2.org> пишет:
> > As I understand, the systemd-run utility returns immediately even with
> > --service-type=forking. What is the proper way then to wait using a shell
> > until the main service process forks the child and exists signaling
> > initialization?
> It is not limited to forking. systemd-run simply queues request to
> start unit, same as systemctl does. It would need to actually wait
> until systemd reports that unit is started.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/systemd-devel/attachments/20150331/cb6a4ccc/attachment.html>

More information about the systemd-devel mailing list