<p dir="ltr">I suggest first porting microupsd itself to a native systemd .service file (so that it'll have process monitoring and everything). That might even fix part of the problem.</p>
<p dir="ltr">Normally services are given a certain amount of time to stop after SIGTERM (or whatever KillSignal was set, or whatever ExecStop command was specified). Even if microupsd doesn't handle SIGTERM nicely (which I'd call a bug), it's possible to add some... arbitrary delays.</p>
<p dir="ltr">Units are stopped due to having automatic Conflicts=shutdown.target, if I remember correctly. I'm not sure if disabling that default dependency is a good approach though...</p>
<p dir="ltr">This time I can't think of a good combination that'd solve both problems without introducing some ugly race conditions...</p>
<br><div class="gmail_quote"><div dir="ltr">On Tue, Aug 8, 2017, 21:46 Marek Floriańczyk <<a href="mailto:marek.florianczyk@gmail.com">marek.florianczyk@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Dnia wtorek, 8 sierpnia 2017 21:04:18 CEST Andrei Borzenkov pisze:<br>
> 08.08.2017 17:03, Marek Floriańczyk пишет:<br>
> > What would be the proper way to distinguish between system is going down<br>
> > for reboot and for shutdown ?<br>
><br>
> Straightforward way is to make your service WantedBy poweroff.target and<br>
> halt.target. You can then have second service WantedBy reboot.target and<br>
> kexec.target. They may even call the same binary (script) but with<br>
> different arguments.<br>
<br>
Thanks for answer,<br>
<br>
So, my binary "microupsd" is started  by /etc/init.d/microups at the boot time<br>
to monitor power input, battery status etc.<br>
During system halt I need to send SIGUSR1 to this "microupsd" process at which<br>
it will send command to microups device, moreover  I would like to give it<br>
some time (like 1-2 seconds) to accomplish the transmission.<br>
I don't need to send anything in case of reboot.<br>
<br>
Should I prepare some script that sends SIGUSR1 to "microupsd" process and<br>
then sleeps for 2 seconds and set it as WantedBy poweroff.target and<br>
halt.target ?<br>
<br>
How can I be sure that this script will be called before "microupsd" is<br>
actually killed during system shutdown ?<br>
<br>
Best Regards<br>
Marek<br>
<br>
_______________________________________________<br>
systemd-devel mailing list<br>
<a href="mailto:systemd-devel@lists.freedesktop.org" target="_blank">systemd-devel@lists.freedesktop.org</a><br>
<a href="https://lists.freedesktop.org/mailman/listinfo/systemd-devel" rel="noreferrer" target="_blank">https://lists.freedesktop.org/mailman/listinfo/systemd-devel</a><br>
</blockquote></div><div dir="ltr">-- <br></div><div class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><p dir="ltr">Mantas Mikulėnas <<a href="mailto:grawity@gmail.com">grawity@gmail.com</a>><br>
Sent from my phone</p>
</div></div>