<div dir="ltr"><div>Okay, thank you: now I see the purpose of systemd's jobs. <br><br></div><div>So, if I get it well: if I want to monitor any kind of service (Type=oneshot, Type=simple, etc.), I need to catch UnitRemoved event and invoke the LoadUnit to get the status of the stopped (either in failure or in success) Unit, right?<br><br></div><div>The tricky part is that calling LoadUnit cause an UnitNew event (which I also monitor) and I may be caught in an infinite loop, because the UnitRemoved is also launched just after... <br><br></div><div>I will be easier if the PropertiesChanged event is also launched on a Unit finishing in success!<br></div><div><br></div><br><div><br><br></div></div><div class="gmail_extra"><br clear="all"><div><div class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><div>Adrien BESNARD</div></div></div></div>
<br><div class="gmail_quote">2016-05-30 14:22 GMT+02:00 Jan Alexander Steffens <span dir="ltr"><<a href="mailto:jan.steffens@gmail.com" target="_blank">jan.steffens@gmail.com</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div><div>Any Start/Stop/Restart operation you issue creates a job that will eventually (almost immediately, when starting a Type=simple service) get completed (or fail) and trigger a JobRemoved signal containing the result.<br><br></div>When StartUnit/StopUnit/etc return they give you the job's object path you need to check the incoming signals against to get the result of the job you issued.<br><br></div>Type=simple services complete their Start job so quickly that you're extremely unlikely to catch them on list-jobs.<div><div class="h5"><br><div><div><div><br><div class="gmail_quote"><div dir="ltr">On Mon, May 30, 2016 at 2:12 PM Adrien Besnard <<a href="mailto:adrien.besnard@gmail.com" target="_blank">adrien.besnard@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div><div>Thank you! I'll try that ASAP. Do I need to listen to JobRemoved because I use the [type=oneshot] or is it the way to do for every kind of service (like [type=simple], for example)? <br><br></div>I'm asking that because I just dicovered that [systemctl list-jobs] lists my [type=oneshot] service when I start it, but I have no idea if it's related or not... <br><br></div><div>Cheers, <br></div></div><div class="gmail_extra"><br clear="all"><div><div data-smartmail="gmail_signature"><div dir="ltr"><div>Adrien BESNARD</div></div></div></div></div><div class="gmail_extra">
<br><div class="gmail_quote">2016-05-26 11:59 GMT+02:00 Jan Alexander Steffens <span dir="ltr"><<a href="mailto:jan.steffens@gmail.com" target="_blank">jan.steffens@gmail.com</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">You need to listen to JobRemoved signals. All of them, before you start your job - trying to match on the specific job you get back from StopUnit might not complete before the job is already removed.<br></div><br><div class="gmail_quote"><div><div><div dir="ltr">On Thu, May 26, 2016 at 8:20 AM Adrien Besnard <<a href="mailto:adrien.besnard@gmail.com" target="_blank">adrien.besnard@gmail.com</a>> wrote:<br></div></div></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div><p dir="ltr">I managed to do what I wanted to do using add_timeout with the GLib's MainLoop: I poll every second the state of the unit and manually call the callback connected to DBus to fake the event when the unit is stopped. </p>
<p dir="ltr">It works but this is a dirty hack. So I'm still interested by a real solution :) </p>
<p dir="ltr">Cheers!</p>
<div class="gmail_quote"></div><div class="gmail_quote">Le 23 mai 2016 11:55, "Adrien Besnard" <<a href="mailto:adrien.besnard@gmail.com" target="_blank">adrien.besnard@gmail.com</a>> a écrit :<br type="attribution"></div><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div><div><div>Hello, <br><br></div>I'm trying to make a small Python script which send an email when a <b>Type=oneshot </b>service ends (either in success or in failure). <br><br></div>To do that, I'm using the dbus binding for Python, and connecting to the <b>PropertiesChanged</b> signal on the unit I'm monitoring. <br><br></div></div></blockquote></div><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div>It works great when the process fails (the signal is triggered and I see <b>ActiveState</b> and <b>SubState</b> refleting the failure) but not when the service end successully. <br><br></div></div></blockquote></div><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div>All I see is an <b>UnitRemoved</b> signal triggered by the manager interface... Is that normal? <br><br></div><div>Do you guys have an idea of what I'm missing here?<br><br></div><div>Thanks! <br></div><div>--<br clear="all"><div><div><div><div dir="ltr"><div>Adrien BESNARD</div></div></div></div>
</div></div></div></blockquote></div></div></div>
_______________________________________________<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>
</blockquote></div><br></div></blockquote></div></div></div></div></div></div></div>
</blockquote></div><br></div>