Project

General

Profile

Task #4594

systemd service files dependency corrections for nfd and associated daemons

Added by John DeHart over 1 year ago. Updated 8 months ago.

Status:
In Progress
Priority:
Normal
Category:
Ubuntu-PPA
Start date:
Due date:
% Done:

80%

Estimated time:

Description

The systemd service files currently in use for Ubuntu 16.04 do not correctly support stopping and restarting
daemons that are dependent on each other. For example when we do a stop of nfd:

systemctl stop nfd

nfd and all the dependent daemons should be stopped. Because it is misconfigured, nfd stops and restarts.

Also, when we try to start nfd:

systemctl start nfd

we would like all the associated daemons to start as well. This does not happen.

To fix this, the nfd.service file should contain this in its Unit section:

Wants=nlsr.service
Wants=nfd-autoreg.service
Wants=nfd-status-http-server.service
Wants=repo-ng.service
Wants=repo-ng2.service
Wants=ndnping.service
Wants=ndn-autoconfig-server.service

And each service listed above (nlsr, nfd-autoreg, nfd-status-http-server, repo-ng, repo-ng2, ndnping and ndn-autoconfig-server) should contain this in its Unit section:

Requires=nfd.service
After=nfd.service

Two of the service files should be corrected in the Package system: nfd-status-http-server.service and nfd-autoreg.service.
nfd-status-http-server.service is missing the Requires=nfd.service.
nfd-autoreg.service has Wants=nfd.service which should be replaced with Requires=nfd.service.

nlsr.service, repo-ng.service, ndnping.service and ndn-autoconfig-server.service are all correct.

repo-ng2.service is a second repo-ng that we set up on the Testbed and will need to be taken care of by the Testbed config scripts.

The nfd.service changes should also probably be taken care of by the Testbed config scripts since not alll
Ubuntu users of NFD will want to include all those daemons.

History

#1 Updated by John DeHart over 1 year ago

Looks like what we really want is to have all the dependent services (nlsr, nfd-autoreg, ...) have this in their Unit section:

BindsTo=nfd.service
After=nfd.service

And this in their Install section:

WantedBy=nfd.service

Then the dependent services need to be re-enabled (systemctl enable nlsr.service ...)

The WantedBy will cause a 'want's symlink to be created for nfd.service.
With this we don't need to add anything to the nfd.service file.

So, there will be a change to all the dependent daemons .service files.

#2 Updated by Davide Pesavento 8 months ago

  • Description updated (diff)
  • Category set to Ubuntu-PPA
  • Status changed from New to In Progress
  • Start date deleted (04/26/2018)
  • % Done changed from 0 to 30

NFD commit f392b8ff44e6456aecc7374211ad60edb3380a13 vastly improves the existing systemd service files for nfd, nfd-autoreg, nfd-status-http-server, ndn-autoconfig-client, ndn-autoconfig-server, and moves them to the NFD repo. The PPA packages should be switched over to the new files.

#3 Updated by Davide Pesavento 8 months ago

John DeHart wrote:

And each service listed above (nlsr, nfd-autoreg, nfd-status-http-server, repo-ng, repo-ng2, ndnping and ndn-autoconfig-server) should contain this in its Unit section:

Requires=nfd.service
After=nfd.service

BindsTo= instead of Requires= is a better solution, as you already said in note-1 and I implemented in NFD commit f392b8ff44e6456aecc7374211ad60edb3380a13.

nfd-status-http-server.service is missing the Requires=nfd.service.

No, nfd-status-http-server does not require NFD to be running in order to start, and can cope with NFD restarting or crashing just fine. The dependency is unnecessary.

nfd-autoreg.service has Wants=nfd.service which should be replaced with Requires=nfd.service.

Changed to BindsTo=nfd.service instead, as explained above.

#4 Updated by Davide Pesavento 8 months ago

John DeHart wrote:

And this in their Install section:

WantedBy=nfd.service

Then the dependent services need to be re-enabled (systemctl enable nlsr.service ...)

The WantedBy will cause a 'want's symlink to be created for nfd.service.
With this we don't need to add anything to the nfd.service file.

This is a much better approach than using Wants=... in nfd.service (which would have been a nonstarter in my opinion). I'm still not 100% comfortable with this though, nfd does not really need any other services, and in many cases it's run alone. But I can accept adding the WantedBy= if you say that it greatly simplifies the management of multiple NDN services that run on top of NFD.

Note that you can achieve the same effect by adding a symlink in nfd.service.wants/ for each "wanted" service, as documented in systemd.unit(5). You can do this locally on your machines if you want this behavior.

#5 Updated by Davide Pesavento 8 months ago

  • % Done changed from 30 to 40

#6 Updated by Davide Pesavento 8 months ago

  • % Done changed from 40 to 50

https://gerrit.named-data.net/c/ndn-tools/+/5125 adds ndn-ping-server.service to ndn-tools repo, with proper BindsTo= and WantedBy= directives

#8 Updated by Davide Pesavento 8 months ago

  • Assignee set to Davide Pesavento

#9 Updated by Davide Pesavento 8 months ago

  • % Done changed from 60 to 70

#10 Updated by Davide Pesavento 8 months ago

  • % Done changed from 70 to 80

https://gerrit.named-data.net/c/NLSR/+/5197 This concludes the set of patches adding improved systemd unit files to the various repositories, unless I missed something.

The remaining 20% of this task is changing the PPA packages to install these new unit files.

Also available in: Atom PDF