Systemd service life cycle

Ralf Mardorf silver.bullet at zoho.com
Sun Apr 10 13:02:40 UTC 2016


On Sun, 10 Apr 2016 13:23:56 +0100, Colin Law wrote:
>It makes a difference to what happens if you issue another start.  If
>Remain is set then the start will do nothing as it is still active, if
>not then it will start it again.

At least if it is a "dependency" for another unit.

I wonder what happens if an active required dependency is unavailable,
while it wasn't stopped by systemctl, but by something else.
Assumed another unit needs it, will it get started again?
The status information is useless.

[root at archlinux rocketmouse]# systemctl status alice-dhcp.service 
● alice-dhcp.service - Alice DHCP
   Loaded: loaded (/usr/lib/systemd/system/alice-dhcp.service; enabled; vendor preset: disabled)
   Active: active (exited) since Sat 2016-04-09 17:04:10 CEST; 21h ago
  Process: 505 ExecStart=/usr/local/sbin/alice-dhcp start (code=exited, status=0/SUCCESS)
 Main PID: 505 (code=exited, status=0/SUCCESS)
    Tasks: 1 (limit: 512)
   CGroup: /system.slice/alice-dhcp.service
           └─636 dhcpcd enp3s0

Apr 09 17:04:10 archlinux alice-dhcp[505]: enp3s0: leased 192.168.1.159 for 604800 seconds
Apr 09 17:04:10 archlinux alice-dhcp[505]: enp3s0: adding route to 192.168.1.0/24
Apr 09 17:04:10 archlinux alice-dhcp[505]: enp3s0: adding default route via 192.168.1.1
Apr 09 17:04:10 archlinux alice-dhcp[505]: forked to background, child pid 636
Apr 09 17:04:10 archlinux systemd[1]: Started Alice DHCP.
Apr 09 17:04:15 archlinux dhcpcd[636]: enp3s0: no IPv6 Routers available
Apr 10 14:48:31 archlinux dhcpcd[636]: enp3s0: carrier lost
Apr 10 14:48:31 archlinux dhcpcd[636]: enp3s0: deleting address fe80::a2c6:6e4c:66ab:9102
Apr 10 14:48:32 archlinux dhcpcd[636]: enp3s0: deleting route to 192.168.1.0/24
Apr 10 14:48:32 archlinux dhcpcd[636]: enp3s0: deleting default route via 192.168.1.1
[root at archlinux rocketmouse]# ps aux | grep 636 | grep -v grep
root       636  0.0  0.0   6732  1784 ?        Ss   Apr09   0:00 dhcpcd enp3s0
[root at archlinux rocketmouse]# alice-dhcp --off

sending signal TERM to pid 636
waiting for pid 636 to exit

[root at archlinux rocketmouse]# pidof dhcpcd 
[root at archlinux rocketmouse]# systemctl status alice-dhcp.service 
● alice-dhcp.service - Alice DHCP
   Loaded: loaded (/usr/lib/systemd/system/alice-dhcp.service; enabled; vendor preset: disabled)
   Active: active (exited) since Sat 2016-04-09 17:04:10 CEST; 21h ago
  Process: 505 ExecStart=/usr/local/sbin/alice-dhcp start (code=exited, status=0/SUCCESS)
 Main PID: 505 (code=exited, status=0/SUCCESS)
    Tasks: 0 (limit: 512)
   CGroup: /system.slice/alice-dhcp.service

Apr 09 17:04:10 archlinux alice-dhcp[505]: enp3s0: adding default route via 192.168.1.1
Apr 09 17:04:10 archlinux alice-dhcp[505]: forked to background, child pid 636
Apr 09 17:04:10 archlinux systemd[1]: Started Alice DHCP.
Apr 09 17:04:15 archlinux dhcpcd[636]: enp3s0: no IPv6 Routers available
Apr 10 14:48:31 archlinux dhcpcd[636]: enp3s0: carrier lost
Apr 10 14:48:31 archlinux dhcpcd[636]: enp3s0: deleting address fe80::a2c6:6e4c:66ab:9102
Apr 10 14:48:32 archlinux dhcpcd[636]: enp3s0: deleting route to 192.168.1.0/24
Apr 10 14:48:32 archlinux dhcpcd[636]: enp3s0: deleting default route via 192.168.1.1
Apr 10 14:49:03 archlinux dhcpcd[636]: received SIGTERM, stopping
Apr 10 14:49:03 archlinux dhcpcd[636]: enp3s0: removing interface

Now there's no Internet access, but the unit is still active.
If I start it without using systemctl either, the unit info gets no
update. Internet is accessible again, but the status still claims the
interface should be removed.

[root at archlinux rocketmouse]# alice-dhcp 

enp3s0: waiting for carrier
enp3s0: carrier acquired
enp3s0: adding address fe80::a2c6:6e4c:66ab:9102
DUID 00:01:00:01:1d:97:14:85:00:1e:8c:80:2a:eb
enp3s0: IAID 8c:80:2a:eb
enp3s0: carrier lost
enp3s0: deleting address fe80::a2c6:6e4c:66ab:9102
enp3s0: carrier acquired
enp3s0: adding address fe80::a2c6:6e4c:66ab:9102
enp3s0: IAID 8c:80:2a:eb
enp3s0: rebinding lease of 192.168.1.159
enp3s0: probing address 192.168.1.159/24
enp3s0: soliciting an IPv6 router
enp3s0: leased 192.168.1.159 for 604800 seconds
enp3s0: adding route to 192.168.1.0/24
enp3s0: adding default route via 192.168.1.1
forked to background, child pid 22181

[root at archlinux rocketmouse]# systemctl status alice-dhcp.service 
● alice-dhcp.service - Alice DHCP
   Loaded: loaded (/usr/lib/systemd/system/alice-dhcp.service; enabled; vendor preset: disabled)
   Active: active (exited) since Sat 2016-04-09 17:04:10 CEST; 21h ago
  Process: 505 ExecStart=/usr/local/sbin/alice-dhcp start (code=exited, status=0/SUCCESS)
 Main PID: 505 (code=exited, status=0/SUCCESS)
    Tasks: 0 (limit: 512)
   CGroup: /system.slice/alice-dhcp.service

Apr 09 17:04:10 archlinux alice-dhcp[505]: enp3s0: adding default route via 192.168.1.1
Apr 09 17:04:10 archlinux alice-dhcp[505]: forked to background, child pid 636
Apr 09 17:04:10 archlinux systemd[1]: Started Alice DHCP.
Apr 09 17:04:15 archlinux dhcpcd[636]: enp3s0: no IPv6 Routers available
Apr 10 14:48:31 archlinux dhcpcd[636]: enp3s0: carrier lost
Apr 10 14:48:31 archlinux dhcpcd[636]: enp3s0: deleting address fe80::a2c6:6e4c:66ab:9102
Apr 10 14:48:32 archlinux dhcpcd[636]: enp3s0: deleting route to 192.168.1.0/24
Apr 10 14:48:32 archlinux dhcpcd[636]: enp3s0: deleting default route via 192.168.1.1
Apr 10 14:49:03 archlinux dhcpcd[636]: received SIGTERM, stopping
Apr 10 14:49:03 archlinux dhcpcd[636]: enp3s0: removing interface
[root at archlinux rocketmouse]# systemctl status alice-dhcp.service 
● alice-dhcp.service - Alice DHCP
   Loaded: loaded (/usr/lib/systemd/system/alice-dhcp.service; enabled; vendor preset: disabled)
   Active: active (exited) since Sat 2016-04-09 17:04:10 CEST; 21h ago
  Process: 505 ExecStart=/usr/local/sbin/alice-dhcp start (code=exited, status=0/SUCCESS)
 Main PID: 505 (code=exited, status=0/SUCCESS)
    Tasks: 0 (limit: 512)
   CGroup: /system.slice/alice-dhcp.service

Apr 09 17:04:10 archlinux alice-dhcp[505]: enp3s0: adding default route via 192.168.1.1
Apr 09 17:04:10 archlinux alice-dhcp[505]: forked to background, child pid 636
Apr 09 17:04:10 archlinux systemd[1]: Started Alice DHCP.
Apr 09 17:04:15 archlinux dhcpcd[636]: enp3s0: no IPv6 Routers available
Apr 10 14:48:31 archlinux dhcpcd[636]: enp3s0: carrier lost
Apr 10 14:48:31 archlinux dhcpcd[636]: enp3s0: deleting address fe80::a2c6:6e4c:66ab:9102
Apr 10 14:48:32 archlinux dhcpcd[636]: enp3s0: deleting route to 192.168.1.0/24
Apr 10 14:48:32 archlinux dhcpcd[636]: enp3s0: deleting default route via 192.168.1.1
Apr 10 14:49:03 archlinux dhcpcd[636]: received SIGTERM, stopping
Apr 10 14:49:03 archlinux dhcpcd[636]: enp3s0: removing interface
[root at archlinux rocketmouse]# ping google.de
PING google.de (172.217.20.3) 56(84) bytes of data.
64 bytes from ham02s13-in-f3.1e100.net (172.217.20.3): icmp_seq=1 ttl=54 time=19.8 ms
64 bytes from ham02s13-in-f3.1e100.net (172.217.20.3): icmp_seq=2 ttl=54 time=19.8 ms
64 bytes from ham02s13-in-f3.1e100.net (172.217.20.3): icmp_seq=3 ttl=54 time=19.8 ms
64 bytes from ham02s13-in-f3.1e100.net (172.217.20.3): icmp_seq=4 ttl=54 time=19.9 ms
64 bytes from ham02s13-in-f3.1e100.net (172.217.20.3): icmp_seq=5 ttl=54 time=20.4 ms
^C
--- google.de ping statistics ---
5 packets transmitted, 5 received, 0% packet loss, time 4006ms
rtt min/avg/max/mdev = 19.823/19.983/20.412/0.216 ms




More information about the ubuntu-users mailing list