"Daemonizing" an application.

G

Gilles Lenfant

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

What are the best practices to do this ? Examples in a well known Pyhon app I could hack ? Is it possible with standard packages only ?

Thanks in advance fo any pointer.
 
C

Chris Angelico

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 :)

ChrisA
 
W

Werner Thie

Hi

Might be an overkill, but have a look at twisted,
http://www.twistedmatrix.com

I usually use the spread package for structured communication between
partners via localhost
What are the best practices to do this ? Examples in a well known Pyhon app I could hack ? Is it possible with standard packages only ?

Have fun, Werner
 
G

Gilles Lenfant

Le mercredi 27 février 2013 11:52:19 UTC+1, Gilles Lenfant a écrit :
Hello again,

And thanks to all for your pointers and ideas.

As the app is already tied to an Unix like OS, I'll go with signal handlingfirst since I can do all I need through reconfiguration (SIGHUP).

If I need other controls, I shall use an XML-RPC, since it's an OTB feature..

Thanks again
 
C

Chris Angelico

Le mercredi 27 février 2013 11:52:19 UTC+1, Gilles Lenfant a écrit :
Hello again,

And thanks to all for your pointers and ideas.

As the app is already tied to an Unix like OS, I'll go with signal handling first since I can do all I need through reconfiguration (SIGHUP).

If I need other controls, I shall use an XML-RPC, since it's an OTB feature.

Sounds good! Definitely go with the simplest possible solution first;
you can always complicate things later.

ChrisA
 
V

Vytas D.

Hello,

Just recently learned about memory-mapped files (module mmap). If two
processes open the same file, this file is mapped for both processes. So at
the same time the same memory space can be accesses by two processes. The
documentation stated that memory-mapped files can (and are) used for
inter-process communication. Also, you can work with the memory-mapped
files using indexing (just like strings).

So you might want to have a look at memory-mapped files if not considered
before. Might help to solve your problem.

Vytas
 
T

Tarek Ziadé

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

What are the best practices to do this ? Examples in a well known Pyhon app I could hack ? Is it possible with standard packages only ?

Thanks in advance fo any pointer.
You can have a look at Circus - https://circus.readthedocs.org which is
a process manager.

"circusctl" is used to control "circusd" using ZeroMQ

The nice thing about zmq as opposed to signals is that you can code your
thing independantly from the transport
then choose which transport fits a situation: TPC (then the ctl can be
on another box), IPC or even ITC

That also means your ctl part can be portable to any platform

Cheers
Tarek
 
G

Gilles Lenfant

Le mercredi 27 février 2013 14:55:42 UTC+1, Tarek Ziadé a écrit :
[...]
Thanks in advance fo any pointer.

You can have a look at Circus - https://circus.readthedocs.org which is

a process manager.



"circusctl" is used to control "circusd" using ZeroMQ



The nice thing about zmq as opposed to signals is that you can code your

thing independantly from the transport

then choose which transport fits a situation: TPC (then the ctl can be

on another box), IPC or even ITC



That also means your ctl part can be portable to any platform

Hi Tarek,

Great stuff. Exactly what I was looking for. The various processes of my app already chat with each other using the great ZeroMQ power sockets. And can potentially be powered in as many physical servers since the shared persistent data are provided through SQLAlchemy + eXist-db.

I can read that Circus can monitor sockets too. Should I understand that I can monitor the state of ZMQ listening sockets with Circus too ?

Cheers
 
G

Gilles Lenfant

Le mercredi 27 février 2013 14:55:42 UTC+1, Tarek Ziadé a écrit :
[...]
Thanks in advance fo any pointer.

You can have a look at Circus - https://circus.readthedocs.org which is

a process manager.



"circusctl" is used to control "circusd" using ZeroMQ



The nice thing about zmq as opposed to signals is that you can code your

thing independantly from the transport

then choose which transport fits a situation: TPC (then the ctl can be

on another box), IPC or even ITC



That also means your ctl part can be portable to any platform

Hi Tarek,

Great stuff. Exactly what I was looking for. The various processes of my app already chat with each other using the great ZeroMQ power sockets. And can potentially be powered in as many physical servers since the shared persistent data are provided through SQLAlchemy + eXist-db.

I can read that Circus can monitor sockets too. Should I understand that I can monitor the state of ZMQ listening sockets with Circus too ?

Cheers
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top