Re: [systemd-devel] blocking service on shutdown
On So, 02.09.18 15:37, Ralf Sieger (ralf.sie...@gmx.net) wrote: >Hi, > >I want my system to pause on shutdown to wait till my backup has finished >if it is running. >For this I've created this small service: > >[Unit] >Description=borg shutdown wait >[Service] >Type=oneshot >ExecStart=/bin/true >RemainAfterExit=true >ExecStop=/usr/local/bin/wait_borg >TimeoutStopSec=600 >[Install] >WantedBy=multi-user.target > >I'm using ubuntu 18.04, systemd 237 > >Manually stopping the service via >systemctl stop borg_wrapper >does wait and thus works. > >But its not working on normal shutdown/poweroff ... >From the logs I can't even see an entry with >"Stopping borg shutdown wait" in syslog. > >Does anyone has an idea? Note that you need to start (i.e. enable) the service first for this to work. In systemd only stuff that is started gets stopped... I presume "wait_borg" talks to some other service "borg" waiting for it to complet what it is doing? Note that with the above you are not ordering the main "borg" service against your wait service, which means the "borg" service might get stopped in parallel with your wait service. You probably want a "After=borg.service" or so in the [Service] section of your wait service (this is because the shutdown order of services is always the reverse of the start-up order of services in systemd, and with After=borg.service you hence say that your service shall be terminated first, and borg.service shall be terminated only after it finished. Lennart -- Lennart Poettering, Red Hat ___ systemd-devel mailing list systemd-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/systemd-devel
Re: [systemd-devel] blocking service on shutdown
Am Di., 4. Sep. 2018 um 18:53 Uhr schrieb Ralf Sieger : > > Well, it does wait when I press the power button on the case. > It does not wait if I enter as root poweroff or reboot. > I assume the first one goes through the logind while the second case does > straight to systemd... > You are correct. Inhibitors (currently) only block if the request comes from an unprivileged user. I guess the reason behind that is, that you could circumvent that anyway, if you are root. See https://github.com/systemd/systemd/issues/2680 Personally I would find it useful if systemd-inhibit would have a switch to also respect inhibitors for root. -- Why is it that all of the instruments seeking intelligent life in the universe are pointed away from Earth? ___ systemd-devel mailing list systemd-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/systemd-devel
Re: [systemd-devel] blocking service on shutdown
Well, it does wait when I press the power button on the case. It does not wait if I enter as root poweroff or reboot. I assume the first one goes through the logind while the second case does straight to systemd... Regards, Ralf Gesendet: Dienstag, 04. September 2018 um 18:40 Uhr Von: "Michael Biebl" An: "Ralf Sieger" Cc: "systemd Mailing List" Betreff: Re: Re: [systemd-devel] blocking service on shutdown 2018-09-04 18:17 GMT+02:00 Ralf Sieger : > Hi Michael, > > this solution has a couple of drawbacks: > - block will let shutdown, etc. fail, I do only need a pause/wait > - delay does not work with reboot It should work for shutdown, i.e. reboot. -- Why is it that all of the instruments seeking intelligent life in the universe are pointed away from Earth? ___ systemd-devel mailing list systemd-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/systemd-devel
Re: [systemd-devel] blocking service on shutdown
2018-09-04 18:17 GMT+02:00 Ralf Sieger : > Hi Michael, > > this solution has a couple of drawbacks: > - block will let shutdown, etc. fail, I do only need a pause/wait > - delay does not work with reboot It should work for shutdown, i.e. reboot. -- Why is it that all of the instruments seeking intelligent life in the universe are pointed away from Earth? ___ systemd-devel mailing list systemd-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/systemd-devel
Re: [systemd-devel] blocking service on shutdown
Hi Michael, this solution has a couple of drawbacks: - block will let shutdown, etc. fail, I do only need a pause/wait - delay does not work with reboot Regards, Ralf Gesendet: Sonntag, 02. September 2018 um 19:15 Uhr Von: "Michael Biebl" An: "Ralf Sieger" Cc: "systemd Mailing List" Betreff: Re: [systemd-devel] blocking service on shutdown 2018-09-02 15:37 GMT+02:00 Ralf Sieger : > Hi, > > I want my system to pause on shutdown to wait till my backup has finished if > it is running. I would suggest using an inhibitor lock when running your backup. See https://www.freedesktop.org/wiki/Software/systemd/inhibit/ That's exactly the use-case it was designed for. -- Why is it that all of the instruments seeking intelligent life in the universe are pointed away from Earth? ___ systemd-devel mailing list systemd-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/systemd-devel
Re: [systemd-devel] blocking service on shutdown
Am 03.09.18 um 00:04 schrieb Amit Saha: > > I had to achieve something similar a while back and this is how I ended > up doing: > > https://echorand.me/doing-something-before-systemd-shuts-your-supervisord-down.html when "ExecStop=/bin/sleep 300" is the solution if want my problems back ___ systemd-devel mailing list systemd-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/systemd-devel
Re: [systemd-devel] blocking service on shutdown
Hi Ralf, On Sun, 2 Sep 2018 at 11:40 pm, Ralf Sieger wrote: > Hi, > > I want my system to pause on shutdown to wait till my backup has finished > if it is running. > For this I've created this small service: > > [Unit] > Description=borg shutdown wait > [Service] > Type=oneshot > ExecStart=/bin/true > RemainAfterExit=true > ExecStop=/usr/local/bin/wait_borg > TimeoutStopSec=600 > [Install] > WantedBy=multi-user.target > > I'm using ubuntu 18.04, systemd 237 > > Manually stopping the service via > systemctl stop borg_wrapper > does wait and thus works. > > But its not working on normal shutdown/poweroff ... > From the logs I can't even see an entry with > "Stopping borg shutdown wait" in syslog. > > Does anyone has an idea? > I had to achieve something similar a while back and this is how I ended up doing: https://echorand.me/doing-something-before-systemd-shuts-your-supervisord-down.html Hope it helps. > Regards, > > Ralf > ___ > systemd-devel mailing list > systemd-devel@lists.freedesktop.org > https://lists.freedesktop.org/mailman/listinfo/systemd-devel > ___ systemd-devel mailing list systemd-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/systemd-devel
Re: [systemd-devel] blocking service on shutdown
Am 02.09.18 um 16:41 schrieb Ralf Sieger: > Hi Harald, > >> what exactly does "/usr/local/bin/wait_borg"? > Small script which terminates whn no "borg" processes exist any more. > >> why are the no dependecnies to the services it waits for? > The process it waits for is not a service but a normal user program. > >> "TimeoutStopSec=600" alone does nothing then prevent systemd kills the >> whole service bfore that timeout is reached at shutdown > You mean at shutdown this timeout is ignored? no, i did not say that - i said it's the timeout after ExecStop will be killed the service below waits as expected until ExecStop has finish which is when VMare Workstation powered off the guest after shtdown within it triggered by open-vm-tools and has a limit of 5 minutes to do so -- [root@srv-rhsoft:~]$ cat /etc/systemd/system/guest-testserver.service [Unit] Description=VMware-Guest Testserver PartOf=vmware-guest.target Requisite=vmware.service After=vmware-vmnet.service iptables.service [Service] Type=oneshot RemainAfterExit=yes Nice=19 IOSchedulingClass=idle User=vmware Group=vmware ExecStart=/usr/bin/vmrun -T ws start '/vms/testserver/config.vmx' nogui ExecReload=-/usr/bin/vmrun -T ws reset '/vms/testserver/config.vmx' nogui soft ExecStop=-/usr/bin/vmrun -T ws stop '/vms/testserver/config.vmx' nogui soft TimeoutSec=300 ReadOnlyPaths=/etc ReadOnlyPaths=/usr CapabilityBoundingSet=~CAP_AUDIT_CONTROL CAP_AUDIT_WRITE CAP_SYS_ADMIN CAP_SYS_BOOT CAP_SYS_PTRACE IPAddressDeny=any IPAddressAllow=localhost [Install] WantedBy=vmware-guest.target ___ systemd-devel mailing list systemd-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/systemd-devel
Re: [systemd-devel] blocking service on shutdown
2018-09-02 15:37 GMT+02:00 Ralf Sieger : > Hi, > > I want my system to pause on shutdown to wait till my backup has finished if > it is running. I would suggest using an inhibitor lock when running your backup. See https://www.freedesktop.org/wiki/Software/systemd/inhibit/ That's exactly the use-case it was designed for. -- Why is it that all of the instruments seeking intelligent life in the universe are pointed away from Earth? ___ systemd-devel mailing list systemd-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/systemd-devel
Re: [systemd-devel] blocking service on shutdown
Hi Harald, > what exactly does "/usr/local/bin/wait_borg"? Small script which terminates whn no "borg" processes exist any more. > why are the no dependecnies to the services it waits for? The process it waits for is not a service but a normal user program. > "TimeoutStopSec=600" alone does nothing then prevent systemd kills the > whole service bfore that timeout is reached at shutdown You mean at shutdown this timeout is ignored? Regards, Ralf Gesendet: Sonntag, 02. September 2018 um 16:17 Uhr Von: "Reindl Harald" An: systemd-devel@lists.freedesktop.org Betreff: Re: [systemd-devel] blocking service on shutdown Am 02.09.18 um 15:37 schrieb Ralf Sieger: > I want my system to pause on shutdown to wait till my backup has > finished if it is running. > For this I've created this small service: > > [Unit] > Description=borg shutdown wait > [Service] > Type=oneshot > ExecStart=/bin/true > RemainAfterExit=true > ExecStop=/usr/local/bin/wait_borg > TimeoutStopSec=600 > [Install] > WantedBy=multi-user.target > > I'm using ubuntu 18.04, systemd 237 > > Manually stopping the service via > systemctl stop borg_wrapper > does wait and thus works. > > But its not working on normal shutdown/poweroff ... > From the logs I can't even see an entry with > "Stopping borg shutdown wait" in syslog. > > Does anyone has an idea? what exactly does "/usr/local/bin/wait_borg"? why are the no dependecnies to the services it waits for? "TimeoutStopSec=600" alone does nothing then prevent systemd kills the whole service bfore that timeout is reached at shutdown ___ systemd-devel mailing list systemd-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/systemd-devel ___ systemd-devel mailing list systemd-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/systemd-devel
Re: [systemd-devel] blocking service on shutdown
Am 02.09.18 um 15:37 schrieb Ralf Sieger: > I want my system to pause on shutdown to wait till my backup has > finished if it is running. > For this I've created this small service: > > [Unit] > Description=borg shutdown wait > [Service] > Type=oneshot > ExecStart=/bin/true > RemainAfterExit=true > ExecStop=/usr/local/bin/wait_borg > TimeoutStopSec=600 > [Install] > WantedBy=multi-user.target > > I'm using ubuntu 18.04, systemd 237 > > Manually stopping the service via > systemctl stop borg_wrapper > does wait and thus works. > > But its not working on normal shutdown/poweroff ... > From the logs I can't even see an entry with > "Stopping borg shutdown wait" in syslog. > > Does anyone has an idea? what exactly does "/usr/local/bin/wait_borg"? why are the no dependecnies to the services it waits for? "TimeoutStopSec=600" alone does nothing then prevent systemd kills the whole service bfore that timeout is reached at shutdown ___ systemd-devel mailing list systemd-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/systemd-devel
[systemd-devel] blocking service on shutdown
Hi, I want my system to pause on shutdown to wait till my backup has finished if it is running. For this I've created this small service: [Unit] Description=borg shutdown wait [Service] Type=oneshot ExecStart=/bin/true RemainAfterExit=true ExecStop=/usr/local/bin/wait_borg TimeoutStopSec=600 [Install] WantedBy=multi-user.target I'm using ubuntu 18.04, systemd 237 Manually stopping the service via systemctl stop borg_wrapper does wait and thus works. But its not working on normal shutdown/poweroff ... From the logs I can't even see an entry with "Stopping borg shutdown wait" in syslog. Does anyone has an idea? Regards, Ralf ___ systemd-devel mailing list systemd-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/systemd-devel