[systemd-devel] Quick ? about ExecStartPre and Restart

Paul D. DeRocco pderocco at ix.netcom.com
Wed Jul 3 17:04:19 PDT 2013


> From: Reindl Harald [mailto:h.reindl at thelounge.net] 
> 
> so make *two* services while the first replaces ExecStartPre
> and it's "ExecStartPost=/usr/bin/systemctl start service2.service"
> 
> "but I want the service to be restarted on success" is generally
> very uncommon and you can hardly have two commands in a single
> service with the opposite behavior

I suppose I could do that. Perhaps there is a cleaner way. All I want to do
is this:

1) I want my service executable to be copied from flash to RAM disk, and
then executed from there, so that the original can be updated while the copy
is running.

2) I want the service to be able to stop itself, and have systemd repeat the
copy operation and run the new copy.

3) If the service actually fails due to a bad configuration, it should die
and stay dead, since restarting it would just fail again.

Seems like a simple pattern that someone must have done before, and it
shouldn't take two services to do it. I thought that the ExecStartPre would
be a good way to do the copy.

I suppose I could also rewrite my service so that it returns a zero exit
code if its initialization fails, and a nonzero exit code if it ever wants
to restart itself, and then use Restart=on-failure. Does that sound
sensible?

-- 

Ciao,               Paul D. DeRocco
Paul                mailto:pderocco at ix.netcom.com 



More information about the systemd-devel mailing list