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

Mantas Mikulėnas grawity at gmail.com
Thu Nov 28 15:59:40 PST 2013


On Nov 29, 2013 1:36 AM, "Cecil Westerhof" <Cecil.Westerhof at snow.nl> wrote:
>
> Thanks for the speedy reply.
>
>
> On 11/29/2013 12:30 AM, Mantas Mikulėnas wrote:
>>
>> On Nov 29, 2013 1:24 AM, "Cecil Westerhof" <Cecil.Westerhof at snow.nl
>> <mailto:Cecil.Westerhof at snow.nl>> wrote:
>>  >
>>  > In a trial presentation I used the following service file:
>>  > [Unit]
>>  > Description=Virtual Distributed Ethernet
>>  > After=syslog.target
>>  >
>>  > [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?
>>
>> 'systemctl start' only starts services, therefore it will do nothing if
>> the service is already started.
>>
>> 'systemctl restart' would stop it and start it again.
>>
>>  > - What happens if someone started the service manually? So bypassing
>> systemd and running directly /usr/bin/vde_switch.
>>
>> As far as systemd is concerned, nothing happens - the manually started
>> vde_switch is just another process inside your login session. It will
>> *not* be automatically pulled into a "service" just because the program
>> name or something happens to match...
>
>
> I should learn to ask my questions better. T_T
>
> What I mend to ask. Someone starts /usr/bin/vde_switch manually and after
that uses systemctl to start it.
>

If the second vde_switch instance is configured to listen on the same
sockets, etc., then... Well, it depends on the daemon itself:

* most will consider this a fatal error, and exit with non-zero status,
causing the systemd .service to fail as well;

* but some will think that the existing socket is stale, will remove it,
and happily start "on top of" the first instance. (Only happens with Unix
sockets, of course; if the daemon uses TCP or tries to grab the same 'tap0'
interface or such, then it can only fail.)

I don't know how vde behaves. It will probably refuse to start.

The best way to find out, of course, is to try systemd yourself.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/systemd-devel/attachments/20131129/9379071e/attachment.html>


More information about the systemd-devel mailing list