Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed3.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.110 X-Spam-Level: * X-Spam-Evidence: '*H*': 0.78; '*S*': 0.00; 'executable': 0.09; 'python': 0.11; 'creates': 0.14; 'times,': 0.14; 'from:addr:torriem': 0.16; 'from:name:michael torrie': 0.16; 'packets.': 0.16; 'subject:under': 0.16; 'threads,': 0.16; 'subject:python': 0.16; 'wrote:': 0.18; 'basically': 0.19; 'creating': 0.23; 'header:User-Agent:1': 0.23; 'script': 0.25; 'post': 0.26; 'header:In-Reply-To:1': 0.27; 'reporting': 0.29; 'thus': 0.29; 'that.': 0.31; 'layer': 0.31; 'file': 0.32; 'this.': 0.32; 'run': 0.32; 'running': 0.33; 'board': 0.35; 'no,': 0.35; 'subject:service': 0.36; 'subject:?': 0.36; 'two': 0.37; '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; 'itself': 0.39; 'to:addr:python.org': 0.39; 'received:org': 0.40; 'read': 0.60; 'you.': 0.62; 'address': 0.63; 'skip:n 10': 0.64; 'networking': 0.64; 'url:blogspot': 0.65; 'periodically': 0.68; 'services.': 0.70; 'serial': 0.72; 'url:2011': 0.75; 'forks': 0.84; 'it\xe2\x80\x99s': 0.84; 'service:': 0.93 X-Virus-Scanned: amavisd-new at torriefamily.org Date: Thu, 11 Sep 2014 20:03:54 -0600 From: Michael Torrie 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: <6B97B7A5-0816-401E-9BDD-A23FFC646985@gmail.com> <20140911212921.GB26465@arxnet.hu> In-Reply-To: <20140911212921.GB26465@arxnet.hu> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 17 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1410488545 news.xs4all.nl 2898 [2001:888:2000:d::a6]:36373 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:77790 On 09/11/2014 03:29 PM, Ervin Hegedüs wrote: >> It basically creates two threads, one which does some local processing and control, the other which periodically does reporting via udp packets. I use the dual threads because they both work with a shared serial port at times, so I have to synchronize access through that. >> >> What I want is to have this startup, after my board has it’s networking layer up and running (and hopefully a valid ip address by then), and to just keep running forever > > may be you think about the fork(), eg: 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.