[Twisted-Python] mktap and twistd

Jean-Paul Calderone exarkun at divmod.com
Thu Mar 8 11:30:16 EST 2007


On Thu, 08 Mar 2007 15:12:27 +0000, John Pote <johnpote at jptechnical.co.uk> wrote:
>Hello all,
>
>I'm just putting together a twisted app that will have an http server for a 
>control UI and a TCP server running my own protocol. I've read the 
>'Configuring and using the Twisted.Web Server' but am a bit confused as to 
>the relation between rolling my own as described at the beginning of the 
>howto and the use of mktap and twistd. Do I take it correctly that mktap 
>makes a simple application that is not particularly adaptable? Assuming I 
>roll my own as shown at the beginning of the howto how does twistd fit in? I 
>seem to remember reading somewhere that twistd was the preferred means of 
>starting a twisted app.

You have the right idea about "mktap web", I think.  It lets you configure
a web server which has some features like serving static files from the file
system and exposing per-user folders and other similar things, but it gives
you no way to add new functionality or customize the behavior beyond what can
be done via the command line arguments it offers.

You can hook your own thing into twistd easily enough, though.  You do this
by making a mktap/twistd plugin, as described here:

  http://twistedmatrix.com/projects/core/documentation/howto/tap.html

This will let you create a tap file using "mktap <your app>" and start
it with "twistd -f <your app>.tap".  Also, starting with Twisted 2.5,
you can skip the mktap step (for your plugin and for all the existing
mktap plugins) and just do "twistd <your app>", which will do the same
thing as the two commands above.

There are also tac files and arbitrary non-IServiceMaker plugins, but
IServiceMaker is probably a good place to start and should take care of
most or all of your needs for now.

>
>I've tried making a simple web server with mktap and twistd which works fine 
>except on my winXP box does not run in the background. This is a winXP 
>limitation I presume.

Yea, no daemonization support in twistd on Windows.  There's some code lying
around someplace to make a service, which is kind of like daemonization I
guess, but it hasn't been integrated with twistd as far as I know.

Jean-Paul




More information about the Twisted-Python mailing list