Example of python service running under systemd?
torriem at gmail.com
Fri Sep 12 05:09:47 CEST 2014
On 09/11/2014 08:29 PM, Chris Angelico wrote:
> On Fri, Sep 12, 2014 at 12:03 PM, Michael Torrie <torriem at gmail.com> wrote:
>> No, you you don't need to do this. Systemd can handle all of that for
>> you. Read up on the docs on creating systemd services. Here's a little
>> blog post that has some good examples, both a non-daemonizing service
>> and a daemonizing service:
>> Any executable file can be turned into a daemon service with systemd
>> (whether or not it forks itself into the background). Thus any python
>> script can easily be run from systemd.
> I strongly recommend making a non-daemonizing service. It's so much
> easier to debug - there's one mode of operation, the script just runs.
> You can then run that directly in a terminal, or via tmux, or via
> systemd - and I've done all three with Yosemite. In fact, I think I
> have instances here on the LAN that are doing all three, right now!
Agreed 100%. If you want to run on a system without systemd, I
recommend using supervisord for turning your program into a daemon.
It also does not require the app to fork.
More information about the Python-list