Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #77792

Re: Example of python service running under systemd?

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!goblin1!goblin.stu.neva.ru!uio.no!news.tele.dk!news.tele.dk!small.news.tele.dk!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <torriem+gmail@torriefamily.org>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.084
X-Spam-Evidence '*H*': 0.83; '*S*': 0.00; 'debug': 0.07; 'executable': 0.09; 'python': 0.11; 'from:addr:torriem': 0.16; 'from:name:michael torrie': 0.16; 'operation,': 0.16; 'subject:under': 0.16; 'subject:python': 0.16; 'wrote:': 0.18; 'app': 0.19; 'creating': 0.23; 'header:User-Agent:1': 0.23; "i've": 0.25; 'script': 0.25; 'post': 0.26; 'header:In-Reply- To:1': 0.27; 'michael': 0.29; 'chris': 0.29; '[1]': 0.29; 'thus': 0.29; 'mode': 0.30; 'strongly': 0.30; 'easier': 0.31; 'sep': 0.31; 'file': 0.32; 'this.': 0.32; 'agreed': 0.32; 'run': 0.32; 'fri,': 0.33; 'no,': 0.35; 'instances': 0.36; 'subject:service': 0.36; 'done': 0.36; 'doing': 0.36; 'subject:?': 0.36; 'url:org': 0.36; 'easily': 0.37; 'message-id:@gmail.com': 0.38; 'handle': 0.38; 'to:addr:python-list': 0.38; 'pm,': 0.38; 'little': 0.38; 'url:01': 0.39; 'does': 0.39; '12,': 0.39; 'itself': 0.39; 'to:addr:python.org': 0.39; 'received:org': 0.40; 'read': 0.60; 'you.': 0.62; 'making': 0.63; 'skip:n 10': 0.64; 'url:blogspot': 0.65; 'here': 0.66; 'fact,': 0.69; 'services.': 0.70; 'url:2011': 0.75; 'forks': 0.84; 'service:': 0.93
X-Virus-Scanned amavisd-new at torriefamily.org
Date Thu, 11 Sep 2014 21:09:47 -0600
From Michael Torrie <torriem@gmail.com>
User-Agent Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20131118 Thunderbird/17.0.11
MIME-Version 1.0
To python-list@python.org
Subject Re: Example of python service running under systemd?
References <FE4C3550-8958-4F72-8AFE-62AA7248D6AF@gmail.com> <CAMw+j7+LQL_+77ejCFVSqWap7Rk9gS_Wu5d3y0gT1UpB8hiZAA@mail.gmail.com> <6B97B7A5-0816-401E-9BDD-A23FFC646985@gmail.com> <20140911212921.GB26465@arxnet.hu> <5412548A.1090507@gmail.com> <CAPTjJmq4fYOs-qvko9q9S=M7PNGOLPBTDiPZ6R0PvMrAULC=3g@mail.gmail.com>
In-Reply-To <CAPTjJmq4fYOs-qvko9q9S=M7PNGOLPBTDiPZ6R0PvMrAULC=3g@mail.gmail.com>
Content-Type text/plain; charset=ISO-8859-1
Content-Transfer-Encoding 7bit
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.13955.1410491465.18130.python-list@python.org> (permalink)
Lines 24
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1410491465 news.xs4all.nl 2829 [2001:888:2000:d::a6]:42504
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:77792

Show key headers only | View raw


On 09/11/2014 08:29 PM, Chris Angelico wrote:
> On Fri, Sep 12, 2014 at 12:03 PM, Michael Torrie <torriem@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:
>>
>> http://patrakov.blogspot.com/2011/01/writing-systemd-service-files.html
>>
>> 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[1] for turning your program into a daemon.
It also does not require the app to fork.

[1] http://supervisord.org/

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

Re: Example of python service running under systemd? Michael Torrie <torriem@gmail.com> - 2014-09-11 21:09 -0600

csiph-web