[Twisted-Python] untwisting twistd

Phil Christensen phil at bubblehouse.org
Mon Jun 22 17:06:50 EDT 2009

On Jun 22, 2009, at 4:30 PM, Jared Gisin wrote:
> Which is iditic as my application may not even expose a –pidfile or  
> a –logfile and it’s definatley not called twistd. The platform  
> specific application runners need to be more generalized so users  
> can write their own twistd equivalent to include only what they want.
> Perhaps I’m missing some key point of twisted that already does  
> this. If so, I’d love to be guided in the right direction. If not,  
> and I’ve got a valid point here, I’d love to know how I can help to  
> remedy this problem. I think it’s great that twistd provides  
> application management classes, but they are unnecessarily  
> intertwined with twistd which should be completely optional.

This topic comes up continuously, but like the other occurrences, it  
makes a gigantic mountain out of a small molehill. The critics are  
usually not thinking about the real requirements of deploying a  
configurable demonizing application in a production environment.

Look at the init script used to start MySQL sometime, particularly  
when installed from a package on a finicky distro like debian. Or  
Apache. Or bind. Or any one of a number of other complex daemons --  
you'll find that it's not usually advisable (or possible) to launch  
any of these daemons without an endless list of command-line options.

The fact is, twistd does a *lot* of stuff for you, so you don't have  
to. This includes dealing with daemonizing in a UNIX-standard way  
(leaving pidfiles behind and logging to a file), and a myriad other  
uses that you may have no need for yet.

Conversely, the things people write with Twisted (and then use twistd  
to execute) come in a million forms from the most complex to the very  
simple, so there's no way to address all the desires of all the  
functionality that someone would want in a tool like twistd.

You said yourself that you should be able to write a python script  
that functions in a certain way, but what makes you think it should be  
integrated into twistd? You could write a wrapper that made use of the  
many other convenient scripting features Twisted provides (such as  
twisted.python.usage.Options) and which would then in turn launch the  
twistd process with the arguments you require, much like MySQL's  
mysqld_safe bootstrap utility.


More information about the Twisted-Python mailing list