[systemd-devel] Create a target unit to start & stop a group of services
林自均
johnlinp at gmail.com
Mon Feb 26 09:24:01 UTC 2018
Hi folks,
I would like to create a target unit to start and stop a group of services.
For example, I want a "my-apps.target" to start and stop "docker.service",
"sshd.service" and "mongodb.service". Here are my units and drop-ins:
# /etc/systemd/system/my-apps.target
[Unit]
Wants=docker.service sshd.service mongodb.service # for starting
# /etc/systemd/system/docker.service.d/my-apps.conf
[Unit]
PartOf=my-apps.target # for stopping
And the drop-ins for "sshd.service" and "mongodb.service" are similar.
Then I can use "systemctl start my-apps.target" and "systemctl stop
my-apps.target" to start and stop the 3 services.
However, it is a little bit tedious to write drop-ins for each service
units. Is there a directive for "my-apps.target" to propagate "stop"
operation to the 3 services? I was expecting something like
"PropagateStopTo=docker.service sshd.service mongodb.service".
Thanks!
John Lin
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/systemd-devel/attachments/20180226/89263f25/attachment.html>
More information about the systemd-devel
mailing list