0

I want to make nginx service dependent on a service I wrote, say abc.service. By dependent, I mean:

  • nginx service should stop when I stop abc
  • nginx service should start when I start abc

A typical way would be to modify /lib/systemd/system/nginx.service and add Wants abc directive. However, I don't want to modify nginx.service file - as this is shipped with nginx package.

Any other way to do this?

1

1 Answer 1

5

Never modify a unit delivered in /lib/systemd/system, those units are shipped by packages owners, and could be overridden at package upgrade.

option 1 : create a copy of the unit in /etc/systemd/system and modify it. then systemctl daemon-reload and you are done. /etc/systemd/system is the place for your local units => https://www.freedesktop.org/software/systemd/man/systemd.unit.html#Unit%20File%20Load%20Path

option 2 : create a drop-in file as suggested by Gerald Schneider.

root@host# mkdir /etc/systemd/system/nginx.service.d root@host# cat /etc/systemd/system/nginx.service.d/mydeps.conf [Unit] Wants=abc.service

you may also need a directive in abc.service to make nginx stop when abc stops.

0

Not the answer you're looking for? Browse other questions tagged .