def run(create_publisher, host='localhost', port=3000, script_name=None, max_children=5): def create_handler(parent_fd): return QuixoteHandler(parent_fd, create_publisher, script_name) s = scgi_server.SCGIServer(create_handler, host=host, port=port, max_children=max_children) s.serve()
def serve_application(application, prefix, port=None, host=None, max_children=None): """ Serve the specified WSGI application via SCGI proxy. ``application`` The WSGI application to serve. ``prefix`` The prefix for what is served by the SCGI Web-server-side process. ``port`` Optional port to bind the SCGI proxy to. Defaults to SCGIServer's default port value. ``host`` Optional host to bind the SCGI proxy to. Defaults to SCGIServer's default host value. ``host`` Optional maximum number of child processes the SCGIServer will spawn. Defaults to SCGIServer's default max_children value. """ class SCGIAppHandler(SWAP): def __init__(self, *args, **kwargs): self.prefix = prefix self.app_obj = application SWAP.__init__(self, *args, **kwargs) kwargs = dict(handler_class=SCGIAppHandler) for kwarg in ('host', 'port', 'max_children'): if locals()[kwarg] is not None: kwargs[kwarg] = locals()[kwarg] scgi_server.SCGIServer(**kwargs).serve()
def main(): if len(sys.argv) == 2: port = int(sys.argv[1]) else: port = scgi_server.SCGIServer.DEFAULT_PORT scgi_server.SCGIServer(port=port).serve()