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

2013-11-28 Thread Cecil Westerhof

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?
- What happens if someone started the service manually? So bypassing 
systemd and running directly /usr/bin/vde_switch.



Met vriendelijke groet,



Cecil Westerhof
Engineer
mobiel +31 - 6 - 25 00 38 81

--

Snow B.V.
Unix Specialists
De Ooyen 11
4191 PB Geldermalsen

http://www.snow.nl
tel. +31 - 345 - 65 66 66
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


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

2013-11-28 Thread Cecil Westerhof

On 11/29/2013 12:23 AM, Cecil Westerhof 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?
- What happens if someone started the service manually? So bypassing
systemd and running directly /usr/bin/vde_switch.


I was not clear here. What I mend: someone starts the service manually 
and after this starts the service with systemctl.

___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


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

2013-11-28 Thread Mantas Mikulėnas
On Nov 29, 2013 1:36 AM, Cecil Westerhof cecil.wester...@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.wester...@snow.nl
 mailto:cecil.wester...@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.
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


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

2013-11-28 Thread Cecil Westerhof

On 11/29/2013 12:59 AM, Mantas Mikulėnas 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.


I need only a generic answer. So if this question is asked I can answer 
with it depends on the service. Making sure that when they ask further I 
remember your explanation.


Thanks.
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


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

2013-11-28 Thread Lennart Poettering
On Fri, 29.11.13 00:23, Cecil Westerhof (cecil.wester...@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
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel