[Twisted-web] deployment with twistd of simple web application
exarkun at twistedmatrix.com
exarkun at twistedmatrix.com
Tue Nov 12 07:04:17 MST 2013
On 01:20 pm, axel.rau at chaos1.de wrote:
>
>Am 08.11.2013 um 19:43 schrieb Axel Rau <Axel.Rau at chaos1.de>:
>>
>>makeService expects a protocol factory, but I have only
>> meteoFactory = Site(resource)
>>How do I interface the former to the http protocol?
>
>
>After fixing my low-level Python errors (sorry for wasting you time),
>the attached plugin works out of the box with my original code:
>---
>resource = RootWeatherPage()
>meteo_factory = Site(resource)
>---
If you want to run multiple services then the pattern to follow is just:
def makeService(config):
parent = MultiService()
oneChild.setServiceParent(parent)
anotherChild.setServiceParent(parent)
...
return parent
You may also want to consider using offering endpoints via the command-
line configuration options. Instead of writing options to explicitly
support IPv4 and IPv6, write an option that accepts an endpoint string
description.
You can see an example of this (sort of) in the implementation of
"twistd mail" which accepts endpoints for several of its option (eg
`--pop3`):
https://twistedmatrix.com/trac/browser/trunk/twisted/mail/tap.py#L103
You can also read about endpoints here:
https://twistedmatrix.com/documents/current/core/howto/endpoints.html
and here:
https://twistedmatrix.com/documents/current/core/howto/servers.html
Jean-Paul
More information about the Twisted-web
mailing list