<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body text="#000000" bgcolor="#FFFFFF">
Hi
<blockquote type="cite" cite="mid:30047552.rSz1lVYx8J@franki">
<pre wrap="">
I have no problem with changing some code in microupsd so it behave in certain
way. It is handling SIGTERM and other signals if needed.
The problem for me is that SIGTERM is send to process during system reboot and
system halt - so I need to differentiate between the two.
</pre>
</blockquote>
SIGTERM is sent, by default, to all processes early during shutdown.
<br>
<br>
You need to disable DefaultDependencies for your process to not
recieve <br>
the default SIGTERM and then trigger it yourself with the WandedBy
that <br>
was already described...<br>
<br>
<br>
Your daemon is a late-shutdown daemon, not a normal daemon. I think
<br>
that deactivating default dependencies in this case makes sense.<br>
<br>
I strongly advice carefully reading the section on default
dependencies in <br>
systemd.service, though... You will deactivate all default
dependencies and <br>
you probably don't want that. You'll need to manually reactivate the
other<br>
default dependencies<br>
<br>
BR<br>
Jérémy<br>
<blockquote type="cite" cite="mid:30047552.rSz1lVYx8J@franki">
<pre wrap="">
If you can suggest me a way, maybe with some example I will change my code.
Best Regards
Marek
</pre>
<blockquote type="cite">
<pre wrap="">
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.
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...
This time I can't think of a good combination that'd solve both problems
without introducing some ugly race conditions...
On Tue, Aug 8, 2017, 21:46 Marek Floriańczyk <a class="moz-txt-link-rfc2396E" href="mailto:marek.florianczyk@gmail.com"><marek.florianczyk@gmail.com></a>
wrote:
</pre>
<blockquote type="cite">
<pre wrap="">Dnia wtorek, 8 sierpnia 2017 21:04:18 CEST Andrei Borzenkov pisze:
</pre>
<blockquote type="cite">
<pre wrap="">08.08.2017 17:03, Marek Floriańczyk пишет:
</pre>
<blockquote type="cite">
<pre wrap="">What would be the proper way to distinguish between system is going
</pre>
</blockquote>
</blockquote>
<pre wrap="">
down
</pre>
<blockquote type="cite">
<blockquote type="cite">
<pre wrap="">for reboot and for shutdown ?
</pre>
</blockquote>
<pre wrap="">
Straightforward way is to make your service WantedBy poweroff.target and
halt.target. You can then have second service WantedBy reboot.target and
kexec.target. They may even call the same binary (script) but with
different arguments.
</pre>
</blockquote>
<pre wrap="">
Thanks for answer,
So, my binary "microupsd" is started by /etc/init.d/microups at the boot
time
to monitor power input, battery status etc.
During system halt I need to send SIGUSR1 to this "microupsd" process at
which
it will send command to microups device, moreover I would like to give it
some time (like 1-2 seconds) to accomplish the transmission.
I don't need to send anything in case of reboot.
Should I prepare some script that sends SIGUSR1 to "microupsd" process and
then sleeps for 2 seconds and set it as WantedBy poweroff.target and
halt.target ?
How can I be sure that this script will be called before "microupsd" is
actually killed during system shutdown ?
Best Regards
Marek
_______________________________________________
systemd-devel mailing list
<a class="moz-txt-link-abbreviated" href="mailto:systemd-devel@lists.freedesktop.org">systemd-devel@lists.freedesktop.org</a>
<a class="moz-txt-link-freetext" href="https://lists.freedesktop.org/mailman/listinfo/systemd-devel">https://lists.freedesktop.org/mailman/listinfo/systemd-devel</a>
</pre>
</blockquote>
</blockquote>
<pre wrap="">
_______________________________________________
systemd-devel mailing list
<a class="moz-txt-link-abbreviated" href="mailto:systemd-devel@lists.freedesktop.org">systemd-devel@lists.freedesktop.org</a>
<a class="moz-txt-link-freetext" href="https://lists.freedesktop.org/mailman/listinfo/systemd-devel">https://lists.freedesktop.org/mailman/listinfo/systemd-devel</a>
</pre>
</blockquote>
<br>
<div class="moz-signature">-- <br>
<div style="border-bottom: 1px solid #ccd4d7; margin:0 10px 10px
0; width:600px"> </div>
<div>
<table style="; padding: 15px 0 0 0" border="0">
<tbody>
<tr>
<td style="font-size:11px; color:#56707d; text-align:
center; "> <a href="http://www.smile.fr/"><img
src="http://ftp.smile.fr/client/Communication/signature/img/Logo.png"
alt="Logo" height="47" width="129"></a><br>
<br>
<font face="century gothic, arial, sans-serif">20 rue
des Jardins<br>
92600 Asnières-sur-Seine<br>
<a href="http://www.smile.fr/" style="font-size:14px;
color:#ec6608 ; text-decoration:none;">www.smile.fr</a></font>
</td>
<td style="padding-left:35px; font-size:12px;
color:#56707d">
<div style="color:#153358; font-size:12px;"><font
face="century gothic, arial, sans-serif"><b>Jérémy
ROSEN</b></font></div>
<div style="color:#117eb4; font-size:12px;"><font
face="century gothic, arial, sans-serif">Architecte
technique<br>
</font></div>
<div style="color:#56707d; font-size:12px;"><font
face="century gothic, arial, sans-serif">Email : <a
href="mailto:jeremy.rosen@smile.fr"
style="color:#56707d; font-size:12px;
text-decoration:none;">jeremy.rosen@smile.fr</a> <br>
Tel : +33141402967 </font></div>
<br>
<div> <span><a
href="https://www.facebook.com/smileopensource"><img
src="http://ftp.smile.fr/client/Communication/signature/img/Facebook.png"
alt="Facebook" height="24" width="25"></a></span>
<span><a
href="http://fr.slideshare.net/SmileOpenSource/presentations"><img
src="http://ftp.smile.fr/client/Communication/signature/img/Slideshare.png"
alt="Google%2B" height="24" width="25"></a></span>
<span><a href="https://www.linkedin.com/company/smile"><img
src="http://ftp.smile.fr/client/Communication/signature/img/LinkedIn.png"
alt="LinkedIn" height="24" width="25"></a></span>
<span><a href="https://twitter.com/GroupeSmile"><img
src="http://ftp.smile.fr/client/Communication/signature/img/Twitter.png"
alt="Twitter" height="24" width="25"></a></span>
</div>
</td>
</tr>
</tbody>
</table>
<div style="border-bottom: 1px solid #ccd4d7; margin:0 10px 0 0;
width:600px"> </div>
<br>
<div> <a
href="http://www.smile.fr/Offres-services/Offres/Ingenierie?utm_source=signature&utm_medium=email&utm_campaign=signature"><img
src="http://signature.smile.eu/assets/img/OW_devient_Smile_ECS.png"
alt="bandeaux_mail" border="0"></a></div>
<br>
<div style="color:#a3acb5; font-size:10px;"> <img
src="http://ftp.smile.fr/client/Communication/signature/img/eco.png"
alt="eco" height="11" width="13"> <font face="century
gothic, arial, sans-serif"> Pour la planète, n'imprimez ce
mail que si c'est nécessaire </font> </div>
</div>
</div>
</body>
</html>