Re: [systemd-devel] systemd oneshot service stop on shutdown problem

2018-09-10 Thread Lennart Poettering
On Mo, 20.08.18 18:00, Radoslaw Garbacz (radoslaw.garb...@xtremedatainc.com) 
wrote:

> Hi,
> 
> Could you please advise me with regard to systemd configuration for service
> type=oneshot.
> It does not execute stop on shutdown/reboot, but works as intended when
> called manually.
> 
> Online discussions indicate that the configuration below should be working.
> 
> 1) service configuration:
> [Unit]
> Description= ### service test ###
> 
> [Service]
> ExecStart=/tmp/aaa.sh start
> ExecStop=/tmp/aaa.sh stop
> Type=oneshot
> RemainAfterExit=yes
> TimeoutStopSec=100
> 
> [Install]
> WantedBy=multi-user.target default.target
> 
> 
> 2) Tried also:
> WantedBy=shutdown.target ...

Did you enable the service? You need to call "systemctl enable …" on
the unit so that the WantedBy= is actually honoured and the unit
linked into the initial and final transaction.

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] systemd oneshot service stop on shutdown problem

2018-08-20 Thread Ryan Gonzalez
Maybe /tmp is getting cleared or unmounted first? What happens if you put
the script somewhere else?

On Mon, Aug 20, 2018, 6:48 PM Filipe Brandenburger 
wrote:

> On Mon, Aug 20, 2018 at 4:00 PM Radoslaw Garbacz
>  wrote:
> > Could you please advise me with regard to systemd configuration for
> service type=oneshot.
> > It does not execute stop on shutdown/reboot, but works as intended when
> called manually.
>
> I can't reproduce this, it works fine for me on reboot, according to
> the journalctl logs below:
>
> $ journalctl -u xdctest
> -- Logs begin at Mon 2018-08-20 23:39:33 UTC, end at Mon 2018-08-20
> 23:43:52 UTC. --
> Aug 20 23:39:45 centos7 systemd[1]: Starting ### service test ###...
> Aug 20 23:39:45 centos7 aaa.sh[353]: BEGIN: TESTING systemd: start
> Aug 20 23:40:04 centos7 aaa.sh[353]: END:   TESTING systemd: start
> Aug 20 23:40:04 centos7 systemd[1]: Started ### service test ###.
> Aug 20 23:42:08 centos7 systemd[1]: Stopping ### service test ###...
> Aug 20 23:42:08 centos7 aaa.sh[1225]: BEGIN: TESTING systemd: stop
> Aug 20 23:42:28 centos7 aaa.sh[1225]: END:   TESTING systemd: stop
> Aug 20 23:42:28 centos7 systemd[1]: Stopped ### service test ###.
> -- Reboot --
> Aug 20 23:42:44 centos7 systemd[1]: Starting ### service test ###...
> Aug 20 23:42:44 centos7 aaa.sh[354]: BEGIN: TESTING systemd: start
> Aug 20 23:43:03 centos7 aaa.sh[354]: END:   TESTING systemd: start
> Aug 20 23:43:03 centos7 systemd[1]: Started ### service test ###.
>
> Only difference from your reported setup is that I have the aaa.sh
> script under /usr/local/bin/ and I only used
> WantedBy=multi-user.target (and not default.target), but I believe
> none of those should make a difference...
>
> Cheers,
> Filipe
> ___
> systemd-devel mailing list
> systemd-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/systemd-devel
>
-- 

Ryan (ライアン)
Yoko Shimomura, ryo (supercell/EGOIST), Hiroyuki Sawano >> everyone else
https://refi64.com/
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/systemd-devel


[systemd-devel] systemd oneshot service stop on shutdown problem

2018-08-20 Thread Radoslaw Garbacz
Hi,

Could you please advise me with regard to systemd configuration for service
type=oneshot.
It does not execute stop on shutdown/reboot, but works as intended when
called manually.

Online discussions indicate that the configuration below should be working.

1) service configuration:
[Unit]
Description= ### service test ###

[Service]
ExecStart=/tmp/aaa.sh start
ExecStop=/tmp/aaa.sh stop
Type=oneshot
RemainAfterExit=yes
TimeoutStopSec=100

[Install]
WantedBy=multi-user.target default.target


2) Tried also:
WantedBy=shutdown.target ...



3) # systemctl status xdctest
● xdctest.service - ### service test ###
   Loaded: loaded (/etc/systemd/system/xdctest.service; enabled; vendor
preset: disabled)
   Active: active (exited) since Mon 2018-08-20 22:43:21 UTC; 1min 13s ago
  Process: 22304 ExecStop=/tmp/aaa.sh stop (code=exited, status=0/SUCCESS)
  Process: 22407 ExecStart=/tmp/aaa.sh start (code=exited, status=0/SUCCESS)
 Main PID: 22407 (code=exited, status=0/SUCCESS)

Aug 20 22:43:01 ip-10-43-215-250.ec2.internal systemd[1]: Starting ###
service test ###...
Aug 20 22:43:01 ip-10-43-215-250.ec2.internal aaa.sh[22407]: BEGIN: TESTING
systemd: start
Aug 20 22:43:21 ip-10-43-215-250.ec2.internal aaa.sh[22407]: END:   TESTING
systemd: start
Aug 20 22:43:21 ip-10-43-215-250.ec2.internal systemd[1]: Started ###
service test ###.



4) # systemctl --version
systemd 219
+PAM +AUDIT +SELINUX +IMA -APPARMOR +SMACK +SYSVINIT +UTMP +LIBCRYPTSETUP
+GCRYPT +GNUTLS +ACL +XZ +LZ4 -SECCOMP +BLKID +ELFUTILS +KMOD +IDN



5) OS: GNU Linux, CentOS 7


Thanks in advance,

-- 
Radoslaw Garbacz
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/systemd-devel