Re: [systemd-devel] service vs target
On Mi, 08.07.20 11:01, Mkrtchyan, Tigran (tigran.mkrtch...@desy.de) wrote: > Dear systemd developers, > > I failed to get the answer to my question from other sources, so > here I am. > > We have a software that consist out of many components. Each component > is a single service, let say A.service, B.service, C.service However, > often you want to be able to start and stop them together. There are > two options that I am aware of: a grouping service of a grouping > target. Target unit's raison d'etre is grouping stuff. Use a target. Lennart -- Lennart Poettering, Berlin ___ systemd-devel mailing list systemd-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/systemd-devel
Re: [systemd-devel] service vs target
Am 08.07.20 um 11:01 schrieb Mkrtchyan, Tigran: > Dear systemd developers, > > I failed to get the answer to my question from other sources, so > here I am. > > We have a software that consist out of many components. Each component > is a single service, let say A.service, B.service, C.service However, > often you want to be able to start and stop them together. There are > two options that I am aware of: a grouping service of a grouping target. > > > I have tried both of them and both works. > > The target based solution doesn't have this artificial service, but sounds too > official - *target*. > >Active: active since Wed 2020-07-08 10:30:03 CEST; 6s ago > > $ systemctl list-dependencies mygroup.target > mygroup.target > ● ├─mygroup@A.service > ● ├─mygroup@B.service > ● └─mygroup@C.service > > > What is the best practice of doing this? targets [root@srv-rhsoft:~]$ systemctl list-dependencies vmware-guest.target vmware-guest.target ● ├─guest-arrakis.service ● ├─guest-esxi.service ● ├─guest-testserver.service ● ├─network-up.service ● ├─vmware-modules.service ● ├─vmware-vmnet.service ● ├─vmware.service ● └─vmware.target ● ├─vmware-authentication.service ● ├─vmware-modules.service ● └─vmware-vmnet.service -- [root@srv-rhsoft:~]$ cat /etc/systemd/system/vmware.target [Unit] Description=VMware Service Group Requires=vmware-modules.service vmware-vmnet.service Wants=vmware-authentication.service [Install] WantedBy=multi-user.target -- [root@srv-rhsoft:~]$ cat /etc/systemd/system/vmware-guest.target [Unit] Description=VMware Guest Group After=vmware.service vmware-modules.service vmware.target vmware-vmnet.service network-up.service Requires=vmware.service vmware-modules.service vmware.target vmware-vmnet.service Wants=network-up.service Wants=guest-arrakis.service Wants=guest-testserver.service Wants=guest-esxi.service [Install] WantedBy=multi-user.target -- [root@srv-rhsoft:~]$ cat /etc/systemd/system/guest-esxi.service [Unit] Description=VMware-Guest ESXi PartOf=vmware-guest.target Requisite=vmware.service After=vmware-vmnet.service network-up.service Wants=network-up.service [Service] Type=oneshot RemainAfterExit=yes Nice=19 IOSchedulingClass=idle User=vmware Group=vmware ExecStart=/usr/bin/vmrun -T ws start '/mnt/data/fileserver/vmware/esx/esx1.vmx' nogui ExecReload=-/usr/bin/vmrun -T ws reset '/mnt/data/fileserver/vmware/esx/esx1.vmx' nogui soft ExecStop=-/usr/bin/vmrun -T ws stop '/mnt/data/fileserver/vmware/esx/esx1.vmx' nogui soft ExecStop=-/usr/bin/sleep 5 TimeoutSec=300 SuccessExitStatus=255 ProtectSystem=full CapabilityBoundingSet=~CAP_AUDIT_CONTROL CAP_AUDIT_WRITE CAP_SYS_ADMIN CAP_SYS_BOOT CAP_SYS_PTRACE IPAddressDeny=any IPAddressAllow=localhost PermissionsStartOnly=true ExecStartPre=-/usr/bin/chgrp vmware /dev/vmnet8 ExecStartPre=-/usr/bin/chmod g+rw /dev/vmnet8 [Install] WantedBy=vmware-guest.target -- ___ systemd-devel mailing list systemd-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/systemd-devel
[systemd-devel] service vs target
Dear systemd developers, I failed to get the answer to my question from other sources, so here I am. We have a software that consist out of many components. Each component is a single service, let say A.service, B.service, C.service However, often you want to be able to start and stop them together. There are two options that I am aware of: a grouping service of a grouping target. I have tried both of them and both works. as service: # mygroup.service [Unit] Description=My handy group as service [Service] Type=oneshot ExecStart=/bin/true ExecReload=/bin/true RemainAfterExit=on [Install] WantedBy=default.target as target: # mygroup.target [Unit] Description=My handy group as target [Install] WantedBy=default.target The option with service looks (and sounds) very natural, however feels quite synthetic: Type=oneshot ExecStart=/bin/true ExecReload=/bin/true RemainAfterExit=on with corresponding status and deps Active: active (exited) since Wed 2020-07-08 09:37:41 CEST; 1min 8s ago Process: 2551 ExecStart=/bin/true (code=exited, status=0/SUCCESS) Main PID: 2551 (code=exited, status=0/SUCCESS) $ systemctl list-dependencies mygroup.service mygroup.service ● ├─mygroup@A.service ● ├─mygroup@B.service ● ├─mygroup@C.service ● ├─system.slice ● └─basic.target ● ├─firewalld.service ... The target based solution doesn't have this artificial service, but sounds too official - *target*. Active: active since Wed 2020-07-08 10:30:03 CEST; 6s ago $ systemctl list-dependencies mygroup.target mygroup.target ● ├─mygroup@A.service ● ├─mygroup@B.service ● └─mygroup@C.service What is the best practice of doing this? Thanks in advance, Tigran. ___ systemd-devel mailing list systemd-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/systemd-devel