Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!feeder.erje.net!eu.feeder.erje.net!eweka.nl!lightspeed.eweka.nl!194.109.133.83.MISMATCH!newsfeed.xs4all.nl!newsfeed4.news.xs4all.nl!xs4all!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.001 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'essentially': 0.04; 'case.': 0.05; 'purpose.': 0.07; 'restarting': 0.07; 'python': 0.09; 'url:github': 0.09; 'cc:addr:python-list': 0.10; 'gui': 0.11; '(say': 0.16; 'batteries': 0.16; 'for,': 0.16; 'gilles': 0.16; 'inputs': 0.16; 'libs': 0.16; 'outputs': 0.16; 'twisted': 0.16; 'wed,': 0.16; 'wrote:': 0.17; 'config': 0.17; 'instance,': 0.17; 'network.': 0.17; 'platforms': 0.18; '(or': 0.18; 'app': 0.19; 'feb': 0.19; 'changes': 0.20; 'email addr:gmail.com>': 0.20; 'bit': 0.21; 'fairly': 0.21; 'regardless': 0.21; 'libraries': 0.22; 'stopping': 0.22; 'title,': 0.22; 'runs': 0.22; 'cc:2**0': 0.23; 'work.': 0.23; '>': 0.23; 'apps': 0.23; 'split': 0.23; 'cc:addr:python.org': 0.25; 'header:In-Reply-To:1': 0.25; 'core': 0.27; 'library.': 0.27; 'message- id:@mail.gmail.com': 0.27; 'chris': 0.28; 'run': 0.28; 'far,': 0.29; 'obscure': 0.29; 'probability': 0.29; 'included': 0.29; 'skip:& 10': 0.29; "i'm": 0.29; 'asking': 0.32; 'file': 0.32; 'good.': 0.32; 'more,': 0.32; 'could': 0.32; 'received:74.125.82': 0.33; 'certain': 0.33; 'controls': 0.33; 'front': 0.33; 'monitor': 0.33; "can't": 0.34; 'received:google.com': 0.34; 'pm,': 0.35; 'there': 0.35; 'explain': 0.36; 'but': 0.36; 'received:74.125': 0.36; 'depends': 0.36; 'subject:" ': 0.36; 'does': 0.37; 'two': 0.37; 'communicate': 0.37; 'some': 0.38; 'hello,': 0.39; 'short': 0.39; 'end': 0.40; 'your': 0.60; 'networking': 0.60; "you'll": 0.62; 'mentioned': 0.63; 'agent': 0.64; 'within': 0.64; 'other.': 0.64; 'unnecessary': 0.65; 'behaviors': 0.71; 'hand': 0.82; '2013': 0.84; 'hardcore': 0.84; 'on?': 0.91 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:x-received:in-reply-to:references:date:message-id :subject:from:to:cc:content-type; bh=XR5kTyVagD/gum84OLes7hJLxeCjruocit/jQtwAsVg=; b=U7yZikr4wuk0EF/+USxHHc7VHWRyH4sA51NfXjc/SkOySVC0/8rjx3M/MhsZn+XkXR dpeQRZpJl9C8ktvQu4U9HDyxs4KZczWMxVgmBLXPPYWMFKy2faboYqUbYPhu8iJmUyDU kH9jO8Q+Lc7RPShGm7q+A4lYPlt629/FbnvDbbkYQ/uOSFxsAHPLnYVIUVJJFQ1SLPpL 5p1GxURz374PLbkU750yl+iAcIf4bpSE3XLyofSm9xwNkjXJjiFM1q84B/E/Y/AHAi1x I0AqgvZv8JDYveQMaAv/kLaEEskJ6/TU09+zLXXxkjDqEphYLJsGD2A0EJk6ZECnq3c0 ktqw== MIME-Version: 1.0 X-Received: by 10.180.95.199 with SMTP id dm7mr3008810wib.20.1361963728544; Wed, 27 Feb 2013 03:15:28 -0800 (PST) In-Reply-To: References: <3e4921b7-fde3-4de7-ab01-1c98ddf63363@googlegroups.com> Date: Wed, 27 Feb 2013 11:15:28 +0000 Subject: Re: "Daemonizing" an application. From: Sven To: Chris Angelico Content-Type: multipart/alternative; boundary=f46d041825ce3caf2f04d6b2e469 Cc: python-list 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: 112 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1361963730 news.xs4all.nl 6923 [2001:888:2000:d::a6]:54209 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:40054 --f46d041825ce3caf2f04d6b2e469 Content-Type: text/plain; charset=ISO-8859-1 On 27 February 2013 11:03, Chris Angelico wrote: > On Wed, Feb 27, 2013 at 9:52 PM, Gilles Lenfant > wrote: > > Hello, > > > > Sorry for the obscure title, but I can't make short to explain what I'm > searching for. :) > > > > I made an app (kind of proxy) that works without UI within it's process. > So far, so good. > > > > Now I need to change "live" some controls of this application, without > stopping it. > > > > So my app will be split in two : > > > > * A control app (say "appctl") for a console UI > > * A daemon (or agent ?) that runs the core of the app (say "appd"), > processing inputs and outputs > > Daemonizing is a fairly specific operation (forking and disconnecting > from the console), which may well be a part of what you're asking for, > but on the other hand may be unnecessary (if, for instance, you let > your core app be invoked by Upstart directly). > > What form of control do you need? With many apps of this nature, the > only control required is Unix signals - particularly SIGHUP, to say > "I've edited your config files, go reread them". Your front end might > do the editing, or you could even abolish the control app altogether > and simply edit the configs manually. But if you need more, you'll > need to work out how you want them to communicate with each other. > > What platform or platforms do you need this to run on? > > Regardless of your answers to the above, I would say that in all > probability *yes*, you will be able to do this with just Python and > the standard library. There are a lot of batteries included with > Python :) > One solution is to use XMLRPC to communicate with the daemonized process. This does involve the daemon listening on the local network. The GUI can then connect to the daemon and send it commands which essentially is calling functions on the daemon. These can then change certain behaviors of the daemon process without restarting it. If you want to be hardcore you can use sockets. There are other networking libs like Twisted and RabbitMQ, but they might be a bit overkill for your purpose. But whether any of this is ok depends on your use case. The signals Chris mentioned will also work. Alternatively there are a number of filewatching libraries like watchdog or https://github.com/seb-m/pyinotify which you can use to monitor changes to a config file if that's the way you want to go. -- ./Sven --f46d041825ce3caf2f04d6b2e469 Content-Type: text/html; charset=ISO-8859-1

On 27 February 2013 11:03, Chris Angelico <rosuav@gmail.com> wrote:
On Wed, Feb 27, 2013 at 9:52 PM, Gilles Lenfant
<gilles.lenfant@gmail.com> wrote:
> Hello,
>
> Sorry for the obscure title, but I can't make short to explain what I'm searching for. :)
>
> I made an app (kind of proxy) that works without UI within it's process. So far, so good.
>
> Now I need to change "live" some controls of this application, without stopping it.
>
> So my app will be split in two :
>
> * A control app (say "appctl") for a console UI
> * A daemon (or agent ?) that runs the core of the app (say "appd"), processing inputs and outputs

Daemonizing is a fairly specific operation (forking and disconnecting
from the console), which may well be a part of what you're asking for,
but on the other hand may be unnecessary (if, for instance, you let
your core app be invoked by Upstart directly).

What form of control do you need? With many apps of this nature, the
only control required is Unix signals - particularly SIGHUP, to say
"I've edited your config files, go reread them". Your front end might
do the editing, or you could even abolish the control app altogether
and simply edit the configs manually. But if you need more, you'll
need to work out how you want them to communicate with each other.

What platform or platforms do you need this to run on?

Regardless of your answers to the above, I would say that in all
probability *yes*, you will be able to do this with just Python and
the standard library. There are a lot of batteries included with
Python :)

One solution is to use XMLRPC to communicate with the daemonized process. This does involve the daemon listening on the local network. The GUI can then connect to the daemon and send it commands which essentially is calling functions on the daemon. These can then change certain behaviors of the daemon process without restarting it. If you want to be hardcore you can use sockets. There are other networking libs like Twisted and RabbitMQ, but they might be a bit overkill for your purpose.

But whether any of this is ok depends on your use case. The signals Chris mentioned will also work. Alternatively there are a number of filewatching libraries like watchdog or https://github.com/seb-m/pyinotify which you can use to monitor changes to a config file if that's the way you want to go.

--
./Sven
--f46d041825ce3caf2f04d6b2e469--