troglobit / pimd

PIM-SM/SSM multicast routing for UNIX and Linux
http://troglobit.com/projects/pimd/
BSD 3-Clause "New" or "Revised" License
197 stars 87 forks source link

Add systemd service file for pimd #41

Closed greenpau closed 7 years ago

greenpau commented 9 years ago

Requesting addition of systemd service file and environments file.

Environments:

cat > /etc/sysconfig/pimd << EOF
# pimd PIM-SM Daemon Environment File
EOF

Service file:

cat > /usr/lib/systemd/system/pimd.service << EOF
[Unit]
Description=pimd PIM-SM Daemon
After=syslog.target network.target
ConditionPathExists=/etc/pimd.conf

[Service]
Type=simple
EnvironmentFile=-/etc/sysconfig/pimd
ExecStart=/usr/local/sbin/pimd -c /etc/pimd.conf -digmp_proto,pim_jp,kernel,pim_register
ExecStop=/usr/local/sbin/pimd -q

[Install]
WantedBy=network.target
EOF

Any thoughts?

greenpau commented 9 years ago
[root@ip-192-168-16-66 ~]# systemctl status pimd
pimd.service - pimd PIM-SM Daemon
   Loaded: loaded (/usr/lib/systemd/system/pimd.service; enabled)
   Active: active (running) since Mon 2015-05-18 19:20:58 UTC; 1s ago
  Process: 3091 ExecStop=/usr/local/sbin/pimd -q (code=exited, status=0/SUCCESS)
 Main PID: 3099 (pimd)
   CGroup: /system.slice/pimd.service
           └─3099 /usr/local/sbin/pimd -c /etc/pimd.conf -digmp_proto pim_jp kernel pim_register

May 18 19:20:58 ip-192-168-16-66 pimd[3099]: 19:20:58.210 RECV    32 bytes IGMP v2 Member Report     from 192.168.16.66   to 224.0.0.2
May 18 19:20:58 ip-192-168-16-66 pimd[3099]: 19:20:58.210 Not creating routing entry for LAN scoped group 224.0.0.2
May 18 19:20:58 ip-192-168-16-66 pimd[3099]: 19:20:58.210 RECV    32 bytes IGMP v2 Member Report     from 192.168.16.66   to 224.0.0.13
May 18 19:20:58 ip-192-168-16-66 pimd[3099]: 19:20:58.210 Not creating routing entry for LAN scoped group 224.0.0.13
May 18 19:20:58 ip-192-168-16-66 pimd[3099]: 19:20:58.210 RECV    32 bytes IGMP v2 Member Report     from 172.17.42.1     to 224.0.0.22
May 18 19:20:58 ip-192-168-16-66 pimd[3099]: 19:20:58.210 Not creating routing entry for LAN scoped group 224.0.0.22
May 18 19:20:58 ip-192-168-16-66 pimd[3099]: 19:20:58.210 RECV    32 bytes IGMP v2 Member Report     from 172.17.42.1     to 224.0.0.2
May 18 19:20:58 ip-192-168-16-66 pimd[3099]: 19:20:58.210 Not creating routing entry for LAN scoped group 224.0.0.2
May 18 19:20:58 ip-192-168-16-66 pimd[3099]: 19:20:58.210 RECV    32 bytes IGMP v2 Member Report     from 172.17.42.1     to 224.0.0.13
May 18 19:20:58 ip-192-168-16-66 pimd[3099]: 19:20:58.210 Not creating routing entry for LAN scoped group 224.0.0.13
[root@ip-192-168-16-66 ~]# 
troglobit commented 9 years ago

I currently have no plans of my own to support systemd, but if you send a patch or GitHub pull request I can merge it. Take a look at Debian, the pimd packare there should get systemd support eventually, if it does not already support it.

greenpau commented 9 years ago

@troglobit, will take a look at it. Thank you.

amluto commented 9 years ago

The ExecStart line should use -f and the ExecStop line should be deleted IMO.

troglobit commented 9 years ago

Admittedly I'm no expert on systemd, but isn't the ExecStop command called to stop a service? In that case pimd -q is the way to do it, unless systemd knows the pid and can stop it by itself of course.

malakudi commented 9 years ago

Unfortunately nobody at debian converted init script to systemd and that's why pimd is no longer available on Debian 8. I installed it manually, then added the following unit.

[Unit]
Description=pimd PIM-SM Daemon
After=syslog.target network.target
ConditionPathExists=/etc/pimd.conf
Documentation=man:pimd

[Service]
Type=forking
EnvironmentFile=-/etc/default/pimd
ExecStart=/usr/local/sbin/pimd -c /etc/pimd.conf
ExecStop=/usr/local/sbin/pimd -q

[Install]
WantedBy=multi-user.target

I would also like to contact debian pimd mentainer for this issue, anyone knows how?

troglobit commented 9 years ago

I haven't heard back from @bobek in a while now. Been meaning to get back in touch with him, but I suspect we will have to build our own packages for Debian/Ubuntu for the time being.

Thank you @malakudi for the unit sample! If I get some time over I'll try to read up on the requirements for debian/packaging of systemd files and add it, unless someone else beats me to it and submits a pull request.

Would be great if we could bring the debian/ directory up to form, that would help pimd being included in Debian/Ubuntu again.

amluto commented 9 years ago

ExecStop is for services that fork or otherwise need help shutting down. pimd should work fine as a "simple" (non-forking) service, and systemd can them send it SIGTERM all by itself, as long as it's started with -f. On Sep 10, 2015 2:48 PM, "Joachim Nilsson" notifications@github.com wrote:

Admittedly I'm no expert on systemd, but isn't the ExecStop command called to stop a service? In that case pimd -q is the way to do it, unless systemd knows the pid and can stop it by itself of course.

— Reply to this email directly or view it on GitHub https://github.com/troglobit/pimd/issues/41#issuecomment-139388464.

troglobit commented 9 years ago

@amluto Good, sounds just like Finit, thanks! :)

malakudi commented 9 years ago

I prefer running without "-f" as I consider this a "debug" option. But yes, if you change Type=simple and ExecStart=/usr/local/sbin/pimd -f -c /etc/pimd.conf , then ExecStop is not needed.

If packaged for debian8 inclusion, it should be ExecStart=/usr/sbin/pimd -c /etc/pimd.conf (removing local)

troglobit commented 9 years ago

@malakudi Why do you consider it a debug option? Many other initd implementations than systemd use this feature of running a process in the foreground.

malakudi commented 9 years ago

Just personal habbit I guess ... I prefer running detached - I guess I am still thinking with the sysvinit way :-)

troglobit commented 9 years ago

@malakudi Ah, OK! :smiley:

Just curious, always good to know how people reason. I was considering updating the documentation at the same time as adding the systemd unit file, so this point might be worth stressing. Thanks!