Re: [systemd-devel] customized shutdown service needed
Am 29.02.2012 17:16, schrieb Lennart Poettering: On Sun, 26.02.12 19:13, Reindl Harald (h.rei...@thelounge.net) wrote: the ExecStop is called but systemd DOES NOT wait until it is finished leading to all virtual machines are killed hard while systemctl stop vmware-default.service does supsend them perfectlly as long it is not combined with any sort of shutdown systemd waits for ExecStop= to finish before executing later jobs (well, subject to a timeout, of a couple of minutes). What really matters is that you order your service before/after the right things, and be aware that: a) the stop order is implicitly the reverse of the start order b) if a job is started and another one stopped and they are ordered against each other, then the stop is executed first, and the start executed second, regardless which kind of ordering is actually configured by the way - somewhere around Fedora 18 without change anything on my side systemd no longer kills ExecStop and so suspending VM's, meaning this was clearly a systemd bug as i reported it ExecStartPost=-/usr/bin/su -c /scripts/vmware/vm-default-start.sh vmware ExecStop=-/scripts/vmware/vm-suspend-all.sh [root@srv-rhsoft:~]$ cat /scripts/vmware/vm-suspend-all.sh #!/usr/bin/bash if [ -x /usr/bin/vmrun ] ; then for i in `pidof vmware-vmx` ; do VMX_PATH=`ps -p $i -f | sed -ne '/vmware/s/.* \(\/.*\.vmx\)/\1/p'` /usr/bin/logger -t vmware SUSPEND: $VMX_PATH /usr/bin/vmrun suspend `ps -p $i -f | sed -ne '/vmware/s/.* \(\/.*\.vmx\)/\1/p'` 2 /dev/null /usr/bin/logger -t vmware SUSPENDED: $VMX_PATH done fi /usr/bin/bash /vmware/permissions.sh exit 0 signature.asc Description: OpenPGP digital signature ___ systemd-devel mailing list systemd-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/systemd-devel
Re: [systemd-devel] customized shutdown service needed
On Wed, 29.02.12 22:12, Burkhard Kayser (kayser-b-2...@t-online.de) wrote: Hi Lennart, based on your recommendation I tried the following service. [Unit] Description=my private startup service Requires=local-fs.target syslog.service nfs.service After=local-fs.target syslog.service nfs.service [Service] ExecStart=/etc/init.d/my_startup start ExecStop=/etc/init.d/my_startup stop Type=oneshot RemainAfterExit=yes TimeoutSec=600 [Install] WantedBy=multi-user.target If this is a sysv init script then systemd will start this service anyway, no need to write a unit file like the above. systemd provides a certain level of compatibility with sysv scripts. This service is started at the very end of the boot sequence. But stopped too late during shutdown. Too late? What do you mean by that? Feb 29 21:48:43 Linux1 logger: starting /etc/init.d/my_shutdown start (1) 1941 ... Feb 29 21:48:43 Linux1 logger: starting /etc/init.d/my_startup stop (1) 1937 ... Hmm, the idea here is that a systemd service is started at bootup, and stopped at shutdown. This output looks like you start and stop it at shutdown. Is there any similar replacement within systemd? Well, for that you actually have to explain after what and before what other services you want your service to be terminated. Lennart -- Lennart Poettering - Red Hat, Inc. ___ systemd-devel mailing list systemd-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/systemd-devel
Re: [systemd-devel] customized shutdown service needed
On Sun, 26.02.12 17:24, Burkhard Kayser (kayser-b-2...@t-online.de) wrote: Hello, I do need a customized shutdown service which performs some clean up tasks, e.g. stopping virtual machines, before the shutdown service of systemd actually starts. The shutdown of the system shall be delayed until my script is terminated. Well, the intended mode of operation here is that services that are started at boot are shut down at shutdown. Hence normally you would place any code you want to run at shutdown in the ExecStop= of the service in question. A number of services are run only at shutdown, and have no counterpart at boot-up. These are special, and live outside the default depndency logic, and need to be marked with DefaultDependencies=no for that. When exactly they are run depends on how you configure things. One possible option here is to order them between shutdown.target and final.target, which makes the server to be started after all normal services are shut down, but before we actually do the low-level termination. If such a service shell complete before we continue with the shut down you need to use Type=oneshot. Before=shutdown.service halt.service There is no shutdown.service. And halt.service is most likely not what you want to use, since it's responsible for actually halting the machine (as opposed to reboot or power it off) DefaultDependencies=no [Service] ExecStart=/etc/init.d/my_shutdown start This is not a SysV script, you should not place it in this directory. Type=oneshot RemainAfterExit=true RemainAfterExit= makes little sense here. Lennart -- Lennart Poettering - Red Hat, Inc. ___ systemd-devel mailing list systemd-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/systemd-devel
Re: [systemd-devel] customized shutdown service needed
On Sun, 26.02.12 19:13, Reindl Harald (h.rei...@thelounge.net) wrote: the ExecStop is called but systemd DOES NOT wait until it is finished leading to all virtual machines are killed hard while systemctl stop vmware-default.service does supsend them perfectlly as long it is not combined with any sort of shutdown systemd waits for ExecStop= to finish before executing later jobs (well, subject to a timeout, of a couple of minutes). What really matters is that you order your service before/after the right things, and be aware that: a) the stop order is implicitly the reverse of the start order b) if a job is started and another one stopped and they are ordered against each other, then the stop is executed first, and the start executed second, regardless which kind of ordering is actually configured. Lennart -- Lennart Poettering - Red Hat, Inc. ___ systemd-devel mailing list systemd-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/systemd-devel
Re: [systemd-devel] customized shutdown service needed
Hi Lennart, based on your recommendation I tried the following service. [Unit] Description=my private startup service Requires=local-fs.target syslog.service nfs.service After=local-fs.target syslog.service nfs.service [Service] ExecStart=/etc/init.d/my_startup start ExecStop=/etc/init.d/my_startup stop Type=oneshot RemainAfterExit=yes TimeoutSec=600 [Install] WantedBy=multi-user.target This service is started at the very end of the boot sequence. But stopped too late during shutdown. cat var/log/messages ... Feb 29 21:48:43 Linux1 sshd[1758]: Exiting on signal 15 Feb 29 21:48:43 Linux1 avahi-daemon[638]: avahi-daemon 0.6.30 exiting. Feb 29 21:48:43 Linux1 systemd[1]: Unit mnt-Server-etc.mount entered failed state. Feb 29 21:48:43 Linux1 umount[1920]: umount: /var/lib/nfs/rpc_pipefs: device is busy. Feb 29 21:48:43 Linux1 umount[1920]: (In some cases useful info about processes that use Feb 29 21:48:43 Linux1 systemd[1]: Unit mnt-Server-Download.mount entered failed state. Feb 29 21:48:43 Linux1 systemd[1]: Unit srv-mywiki.mount entered failed state. Feb 29 21:48:43 Linux1 umount[1920]: the device is found by lsof(8) or fuser(1)) Feb 29 21:48:43 Linux1 systemd[1]: var-lib-nfs-rpc_pipefs.mount mount process exited, code=exited status=1 Feb 29 21:48:43 Linux1 systemd[1]: Unit mnt-Server-tmp.mount entered failed state. Feb 29 21:48:43 Linux1 logger: starting /etc/init.d/my_shutdown start (1) 1941 ... Feb 29 21:48:43 Linux1 logger: starting /etc/init.d/my_startup stop (1) 1937 ... Feb 29 21:48:43 Linux1 my_shutdown[1941]: + case $1 in Feb 29 21:48:43 Linux1 my_shutdown[1941]: + echo 'Wed Feb 29 21:48:43 CET 2012: /etc/init.d/my_shutdown start' Feb 29 21:48:43 Linux1 my_shutdown[1941]: ++ date Feb 29 21:48:43 Linux1 my_startup[1937]: + echo stop Feb 29 21:48:43 Linux1 my_startup[1937]: + /usr/bin/truecrypt --text --list Feb 29 21:48:43 Linux1 my_shutdown[1941]: + D='Wed Feb 29 21:48:43 CET 2012' Feb 29 21:48:43 Linux1 my_shutdown[1941]: + echo 'Wed Feb 29 21:48:43 CET 2012: /etc/init.d/my_shutdown start done' Feb 29 21:48:43 Linux1 my_shutdown[1941]: + logger '/etc/init.d/my_shutdown done' Feb 29 21:48:43 Linux1 logger: /etc/init.d/my_shutdown done Feb 29 21:48:43 Linux1 httpd2[1955]: httpd2: Could not reliably determine the server's fully qualified domain name, using 192.168.1.27 for ServerName Feb 29 21:48:43 Linux1 sshd[1705]: Received signal 15; terminating. Feb 29 21:48:43 Linux1 ntpd[1736]: ntpd exiting on signal 15 Feb 29 21:48:43 Linux1 my_startup[1937]: Error: No volumes mounted. Feb 29 21:48:43 Linux1 my_startup[1937]: + /usr/bin/truecrypt --text --non-interactive --dismount /mnt/tc Feb 29 21:48:43 Linux1 my_startup[1937]: Error: No such volume is mounted. Feb 29 21:48:43 Linux1 my_startup[1937]: + echo 'stop done' Feb 29 21:48:43 Linux1 my_startup[1937]: + logger '/etc/init.d/my_startup done' Feb 29 21:48:43 Linux1 logger: /etc/init.d/my_startup done Feb 29 21:48:43 Linux1 kernel: Kernel logging (proc) stopped. Feb 29 21:48:43 Linux1 rsyslogd: [origin software=rsyslogd swVersion=5.8.5 x-pid=619 x-info=http://www.rsyslog.com;] exiting on signal 15. I do have several scripts which shall be executed once the machine is fully up and running and just before the shutdown sequence starts stopping any service. This was so far working fine with legacy SysV init. Is there any similar replacement within systemd? Regards Burkhard On 29/02/12 17:10, Lennart Poettering wrote: On Sun, 26.02.12 17:24, Burkhard Kayser (kayser-b-2...@t-online.de) wrote: Hello, I do need a customized shutdown service which performs some clean up tasks, e.g. stopping virtual machines, before the shutdown service of systemd actually starts. The shutdown of the system shall be delayed until my script is terminated. Well, the intended mode of operation here is that services that are started at boot are shut down at shutdown. Hence normally you would place any code you want to run at shutdown in the ExecStop= of the service in question. A number of services are run only at shutdown, and have no counterpart at boot-up. These are special, and live outside the default depndency logic, and need to be marked with DefaultDependencies=no for that. When exactly they are run depends on how you configure things. One possible option here is to order them between shutdown.target and final.target, which makes the server to be started after all normal services are shut down, but before we actually do the low-level termination. If such a service shell complete before we continue with the shut down you need to use Type=oneshot. Before=shutdown.service halt.service There is no shutdown.service. And halt.service is most likely not what you want to use, since it's responsible for actually halting the machine (as opposed to reboot or power it off) DefaultDependencies=no [Service] ExecStart=/etc/init.d/my_shutdown start This is not a SysV script, you should not place it in
Re: [systemd-devel] customized shutdown service needed
Hi I tried as well the following configuration. My script shall be started before ANY other service is shut down. Stopping a virtual machine is only one example. Synchronizing data into a truecrypt container another. [Unit] Description=my shutdown service Before=shutdown.service halt.service shutdown.target umount.target DefaultDependencies=no [Service] ExecStart=/etc/init.d/my_shutdown start Type=oneshot RemainAfterExit=true TimeoutSec=600 [Install] WantedBy=shutdown.target My script is started almost at the end of the shutdown sequence. See var/log/messages below. Feb 28 20:26:54 Linux1 systemd[1]: alsa-store.service: main process exited, code=exited, status=19 Feb 28 20:26:54 Linux1 systemd[1]: Unit alsa-store.service entered failed state. Feb 28 20:26:54 Linux1 sshd[2233]: Exiting on signal 15 Feb 28 20:26:54 Linux1 alsactl[2391]: /usr/sbin/alsactl: save_state:1519: No soundcards found... Feb 28 20:26:54 Linux1 haveged: haveged stopping due to signal 15 Feb 28 20:26:54 Linux1 umount[2374]: umount: /var/lib/nfs/rpc_pipefs: device is busy. Feb 28 20:26:54 Linux1 umount[2374]: (In some cases useful info about processes that use Feb 28 20:26:54 Linux1 avahi-daemon[652]: avahi-daemon 0.6.30 exiting. Feb 28 20:26:54 Linux1 umount[2374]: the device is found by lsof(8) or fuser(1)) Feb 28 20:26:54 Linux1 systemd[1]: var-lib-nfs-rpc_pipefs.mount mount process exited, code=exited status=1 Feb 28 20:26:55 Linux1 systemd[1]: Unit mnt-Server-etc.mount entered failed state. Feb 28 20:26:55 Linux1 systemd[1]: Unit srv-mywiki.mount entered failed state. Feb 28 20:26:55 Linux1 systemd[1]: Unit mnt-Server-tmp.mount entered failed state. Feb 28 20:26:55 Linux1 systemd[1]: Unit mnt-Server-Download.mount entered failed state. Feb 28 20:26:55 Linux1 logger: starting /etc/init.d/my_shutdown start (1) 2392 ... Feb 28 20:26:55 Linux1 my_shutdown[2392]: + case "$1" in Feb 28 20:26:55 Linux1 my_shutdown[2392]: + echo 'Tue Feb 28 20:26:55 CET 2012: /etc/init.d/my_shutdown start' Feb 28 20:26:55 Linux1 my_shutdown[2392]: ++ date Feb 28 20:26:55 Linux1 my_shutdown[2392]: + D='Tue Feb 28 20:26:55 CET 2012' Feb 28 20:26:55 Linux1 my_shutdown[2392]: + echo 'Tue Feb 28 20:26:55 CET 2012: /etc/init.d/my_shutdown start done' Feb 28 20:26:55 Linux1 my_shutdown[2392]: + logger '/etc/init.d/my_shutdown done' Feb 28 20:26:55 Linux1 logger: /etc/init.d/my_shutdown done Feb 28 20:26:55 Linux1 sshd[1780]: Received signal 15; terminating. Feb 28 20:26:55 Linux1 httpd2[2395]: httpd2: Could not reliably determine the server's fully qualified domain name, using 192.168.1.27 for ServerName Feb 28 20:26:55 Linux1 ntpd[1801]: ntpd exiting on signal 15 Feb 28 20:26:55 Linux1 kernel: Kernel logging (proc) stopped. Feb 28 20:26:55 Linux1 rsyslogd: [origin software="rsyslogd" swVersion="5.8.5" x-pid="623" x-info="http://www.rsyslog.com"] exiting on signal 15. On 27/02/12 01:49, Eduardo Tongson wrote: On Sun, Feb 26, 2012 at 4:24 PM, Burkhard Kayser kayser-b-2...@t-online.de wrote: Hello, I do need a customized shutdown service which performs some clean up tasks, e.g. stopping virtual machines, before the shutdown service of systemd actually starts. The shutdown of the system shall be delayed until my script is terminated. I could not find a suitable configuration. The "templates" in /lib/systemd did not help. I've an OpenSuSE 12.1 system with latest patches installed. Here is my configuration: [Unit] Description=my shutdown service Before=shutdown.service halt.service DefaultDependencies=no [Service] ExecStart=/etc/init.d/my_shutdown start Type=oneshot RemainAfterExit=true [Install] WantedBy=shutdown.target Can please somebody point me to the right configuration? Thanks for your help. Regards Burkhard ___ systemd-devel mailing list systemd-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/systemd-devel This works consistently in my setup: [Unit] DefaultDependencies=no Before=shutdown.target [Service] Type=oneshot ExecStart=script ___ systemd-devel mailing list systemd-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/systemd-devel -- Burkhard Kayser Im Stiegel 9 D-71549 Auenwald Phone: +49 7191 58288 Mobile: +49 160 9136 8972 This communication is confidential and intended solely for the addressee(s). Any unauthorized review, use, disclosure or distribution is prohibited. If
[systemd-devel] customized shutdown service needed
Hello, I do need a customized shutdown service which performs some clean up tasks, e.g. stopping virtual machines, before the shutdown service of systemd actually starts. The shutdown of the system shall be delayed until my script is terminated. I could not find a suitable configuration. The "templates" in /lib/systemd did not help. I've an OpenSuSE 12.1 system with latest patches installed. Here is my configuration: [Unit] Description=my shutdown service Before=shutdown.service halt.service DefaultDependencies=no [Service] ExecStart=/etc/init.d/my_shutdown start Type=oneshot RemainAfterExit=true [Install] WantedBy=shutdown.target Can please somebody point me to the right configuration? Thanks for your help. Regards Burkhard ___ systemd-devel mailing list systemd-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/systemd-devel
Re: [systemd-devel] customized shutdown service needed
Am 26.02.2012 17:24, schrieb Burkhard Kayser: Hello, I do need a customized shutdown service which performs some clean up tasks, e.g. stopping virtual machines, before the shutdown service of systemd actually starts. The shutdown of the system shall be delayed until my script is terminated. I could not find a suitable configuration. The templates in /lib/systemd did not help. I've an OpenSuSE 12.1 system with latest patches installed. Here is my configuration: [Unit] Description=my shutdown service Before=shutdown.service halt.service DefaultDependencies=no [Service] ExecStart=/etc/init.d/my_shutdown start Type=oneshot RemainAfterExit=true [Install] WantedBy=shutdown.target the same still here since updatd to F15 the ExecStop is called but systemd DOES NOT wait until it is finished leading to all virtual machines are killed hard while systemctl stop vmware-default.service does supsend them perfectlly as long it is not combined with any sort of shutdown [root@srv-rhsoft:~]$ cat /etc/systemd/system/vmware-default.service [Unit] Description=VMware-Default-Machines After=vmware.service [Service] Type=oneshot ExecStart=/bin/su -c /scripts/vmware/vm-default-start.sh vmware ExecStop=/scripts/vmware/vm-suspend-all.sh RemainAfterExit=yes TimeoutSec=600 SysVStartPriority=90 [Install] WantedBy=multi-user.target signature.asc Description: OpenPGP digital signature ___ systemd-devel mailing list systemd-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/systemd-devel
Re: [systemd-devel] customized shutdown service needed
This is relevant to my interests too. On Sunday, February 26, 2012 19:13:21 Reindl Harald wrote: Am 26.02.2012 17:24, schrieb Burkhard Kayser: Hello, I do need a customized shutdown service which performs some clean up tasks, e.g. stopping virtual machines, before the shutdown service of systemd actually starts. The shutdown of the system shall be delayed until my script is terminated. I could not find a suitable configuration. The templates in /lib/systemd did not help. I've an OpenSuSE 12.1 system with latest patches installed. Here is my configuration: [Unit] Description=my shutdown service Before=shutdown.service halt.service DefaultDependencies=no [Service] ExecStart=/etc/init.d/my_shutdown start Type=oneshot RemainAfterExit=true [Install] WantedBy=shutdown.target the same still here since updatd to F15 the ExecStop is called but systemd DOES NOT wait until it is finished leading to all virtual machines are killed hard while systemctl stop vmware-default.service does supsend them perfectlly as long it is not combined with any sort of shutdown [root@srv-rhsoft:~]$ cat /etc/systemd/system/vmware-default.service [Unit] Description=VMware-Default-Machines After=vmware.service [Service] Type=oneshot ExecStart=/bin/su -c /scripts/vmware/vm-default-start.sh vmware ExecStop=/scripts/vmware/vm-suspend-all.sh RemainAfterExit=yes TimeoutSec=600 SysVStartPriority=90 [Install] WantedBy=multi-user.target ___ systemd-devel mailing list systemd-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/systemd-devel
Re: [systemd-devel] customized shutdown service needed
On Sun, Feb 26, 2012 at 4:24 PM, Burkhard Kayser kayser-b-2...@t-online.de wrote: Hello, I do need a customized shutdown service which performs some clean up tasks, e.g. stopping virtual machines, before the shutdown service of systemd actually starts. The shutdown of the system shall be delayed until my script is terminated. I could not find a suitable configuration. The templates in /lib/systemd did not help. I've an OpenSuSE 12.1 system with latest patches installed. Here is my configuration: [Unit] Description=my shutdown service Before=shutdown.service halt.service DefaultDependencies=no [Service] ExecStart=/etc/init.d/my_shutdown start Type=oneshot RemainAfterExit=true [Install] WantedBy=shutdown.target Can please somebody point me to the right configuration? Thanks for your help. Regards Burkhard ___ systemd-devel mailing list systemd-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/systemd-devel This works consistently in my setup: [Unit] DefaultDependencies=no Before=shutdown.target [Service] Type=oneshot ExecStart=script ___ systemd-devel mailing list systemd-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/systemd-devel