[systemd-devel] What if a service is started manually

Lennart Poettering lennart at poettering.net
Thu Nov 28 19:07:46 PST 2013


On Fri, 29.11.13 00:23, Cecil Westerhof (Cecil.Westerhof at Snow.nl) wrote:

> In a trial presentation I used the following service file:
> [Unit]
> Description=Virtual Distributed Ethernet
> After=syslog.target

In curretn systemd versions the After=syslog.target is unnecessary. 

> 
> [Service]
> Type=forking
> PIDFile=/var/run/vde.pid
> # Note the -f: don't fail if there is no PID file
> ExecStartPre=/bin/rm -f /var/run/vde.pid
> ExecStart=/usr/bin/vde_switch --tap tap0 --mode 0660 \
>  --dirmode 0750 --group qemu \
>  --daemon --pidfile /var/run/vde.pid
> Restart=on-abort
> 
> [Install]
> WantedBy=multi-user.target
> 
> Here the PID file is removed before the service is started.
> 
> This brought up two questions.
> - What happens is you start a service that you already started?
> Nothing, or is the service first stopped and then again started?

A started service is unaffected by yet another start request.

If two clients request the same service to start and wait for it to
complete, then the two start jobs are coalesced and only one instance is
started with both clients waiting for the startup of that same instance
to finish.

> - What happens if someone started the service manually? So bypassing
> systemd and running directly /usr/bin/vde_switch.

If you start things on the shell, then systemd won't know about it. It's
exactly the same as if you ran the daemon binary twice on a classic
sysvinit system: it's up to the daemon how it deals with that. Most
daemons will check for PID files and refuse starting twice...

Lennart

-- 
Lennart Poettering, Red Hat


More information about the systemd-devel mailing list