<div dir="ltr">thanks to both Amit and Colin. I'm going to see what we can throw together. Will try to remember to share back what we come up with.<br></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Mon, Jan 27, 2014 at 6:46 PM, Amit Saha <span dir="ltr"><<a href="mailto:asaha@redhat.com" target="_blank">asaha@redhat.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="im"><br>
<br>
----- Original Message -----<br>
> From: "Greg Swift" <<a href="mailto:gregswift@gmail.com">gregswift@gmail.com</a>><br>
> To: <a href="mailto:systemd-devel@lists.freedesktop.org">systemd-devel@lists.freedesktop.org</a><br>
> Sent: Tuesday, January 28, 2014 3:20:46 AM<br>
> Subject: [systemd-devel] making a python daemon both systemd and el5 compatible<br>
><br>
> I'm working on a small daemon[1] that doesn't do a whole lot, but we need<br>
> it to work on RHEL5+. Going out of the gate I want to ensure it also works<br>
> with systemd, since i want it to be usable on fedora and el7.<br>
><br>
> This stackoverflow[2] has a method, but then mentions some compatibility<br>
> problems with the library it recommends that seem like it will not make it<br>
> to friendly back to el5.<br>
><br>
> In the interm I was going to try leveraging cherrypy's bits (PIDFile and<br>
> Daemonize), but they aren't backwards compatible to EL5, so we have to fix<br>
> that.<br>
><br>
> I tried to find some place where this was mentioned or recommended but my<br>
> google-fu failed me.<br>
><br>
> Do you have any recommendations or a existing python daemon that you could<br>
> point me at that has similar needs?<br>
<br>
</div>The Beaker project's daemons (beakerd, beaker-proxy, beaker-watchdog and beaker-provision)<br>
adopts a policy that if it is on a distro which doesn't have<br>
systemd, it uses the SysV init files and vice-versa. The spec file here [1]<br>
should give you some idea about what we are doing.<br>
<br>
Specifically, w.r.t python-daemon, on the SO thread you mention, I had replied<br>
with my experience here [2] and I wrote further on this here [3].<br>
<br>
Specifically, this may be helpful for you:<br>
<br>
"In the [Service] section, the Type is set to Forking. This is because, beakerd<br>
uses python-daemon which forks itself (detaches itself) during the daemonization.<br>
However, you must ensure that when creating a DaemonContext() object, you should<br>
specify detach_process=True. This is because, if python-daemon detects that it<br>
is running under a init manager, it doesn’t detach itself unless the keyword is<br>
explicitly set to True, as above (you can see the code in daemon.py).<br>
Hence, although not setting the above keyword would work under SysV Init, it doesn’t<br>
work under systemd (with Type=Forking), since the daemon doesn’t fork at all and<br>
systemd expects it to fork (and finally kills it). The PIDFile specifies where the<br>
process ID is dumped by beakerd and is setup while creating the DaemonContext object<br>
as follows and ExecStart specifies the location to the binary that is to be started."<br>
<br>
<br>
[1] <a href="http://git.beaker-project.org/cgit/beaker/plain/beaker.spec?h=develop" target="_blank">http://git.beaker-project.org/cgit/beaker/plain/beaker.spec?h=develop</a><br>
[2] <a href="http://stackoverflow.com/a/17848250" target="_blank">http://stackoverflow.com/a/17848250</a><br>
[3] <a href="http://echorand.me/2013/08/02/notes-on-writing-systemd-unit-files-for-beakers-daemon-processes/" target="_blank">http://echorand.me/2013/08/02/notes-on-writing-systemd-unit-files-for-beakers-daemon-processes/</a><br>
<br>
Hope those give you some ideas and point you towards the right direction.<br>
<br>
Best,<br>
Amit.<br>
<span class="HOEnZb"><font color="#888888"><br>
--<br>
Amit Saha <<a href="http://echorand.me" target="_blank">http://echorand.me</a>><br>
<br>
</font></span></blockquote></div><br></div>