Beispiel #1
0
def fcgi_tcp(application, host='127.0.0.1', port=9000):
    """
    $0 fcgi_tcp [host [port]]

    Defaults to listening on 127.0.0.1, port 9000
    """
    fcgi.WSGIServer(application, bindAddress=(host, int(port))).run()
Beispiel #2
0
        else:
            return BaseHTTPServer.HTTPServer.process_request(self,*p)
def qweb_wsgi_autorun(wsgiapp,ip='127.0.0.1',port=8080,threaded=1,log=1,callback_ready=None):
    if sys.platform=='win32':
        fcgi=0
    else:
        fcgi=1
        sock = socket.fromfd(0, socket.AF_INET, socket.SOCK_STREAM)
        try:
            sock.getpeername()
        except socket.error, e:
            if e[0] == errno.ENOTSOCK:
                fcgi=0
    if fcgi or os.environ.has_key('REQUEST_METHOD'):
        import fcgi
        fcgi.WSGIServer(wsgiapp,multithreaded=False).run()
    else:
        if log:
            print 'Serving on %s:%d'%(ip,port)
        s=QWebWSGIServer(wsgiapp,ip=ip,port=port,threaded=threaded,log=log)
        if callback_ready:
            callback_ready()
        try:
            s.serve_forever()
        except KeyboardInterrupt,e:
            sys.excepthook(*sys.exc_info())

#----------------------------------------------------------
# Qweb Documentation
#----------------------------------------------------------
def qweb_doc():
Beispiel #3
0
def fcgi_unix(application, path):
    """
    $0 fcgi_unix path
    """
    fcgi.WSGIServer(application, bindAddress=path).run()
Beispiel #4
0
        util.wrap_static(application, app_path,
            index='wakaba.html',
            not_found_handler=app.not_found),
        use_reloader=True, use_debugger=config.DEBUG)

def main():
    # Set up tentative environment variables.
    local.environ['waka.rootpath'] \
        = os.path.join('/', config.BOARD_DIR, '')
    try:
        app.init_database()
    except model.OperationalError, e:
        # CGI-friendly error message
        print "Content-Type: text/plain\n"
        print "Error initializing database: %s" % e.args[0]
        return

    arg = sys.argv[1:] and sys.argv[1] or 'fcgi'
    if arg == 'fcgi':
        fcgi.WSGIServer(application).run()
    elif arg == 'reset_password':
        reset_password(sys.argv[2])
    elif arg in ('rebuild_cache', 'rebuild_global_cache',
                         'delete_by_ip'):
        worker_commands(arg, sys.argv[2:])
    else:
        development_server()

if __name__ == '__main__':
    main()