def runcherrypyserver(argset=[], **kwargs):
    # Get the options
    options = CPWSGI_OPTIONS.copy()
    options.update(kwargs)
    for x in argset:
        if "=" in x:
            k, v = x.split('=', 1)
        else:
            k, v = x, True
        if v=='False' or v=='false':
            v = False
        options[k.lower()] = v

    if "help" in options:
        print CPWSGI_HELP
        return

    if "stop" in options:
        if options['pidfile']:
            stop_server(options['pidfile'])
            return True
        if options['host'] and options['port']:
            #fall through into the following host/port shutdown sequence
            pass
        else:
            raise Exception("must have pidfile or host+port")

    if port_is_available(options['host'], options['port']):
        pass
    else:
        # is kalite running on that port?
        existing_server_pid = ka_lite_is_using_port(options['host'], options['port'])
        if existing_server_pid:
            stop_server_using_pid(existing_server_pid)
            # try again, is kalite still running on that port?
            time.sleep(5.0)
            existing_server_pid = ka_lite_is_using_port(options['host'], options['port'])
            if existing_server_pid:
                raise Exception("Existing kalite process cannot be stopped")
        else:
            raise Exception("Port %s is currently in use by another process, cannot continue" % options['port'])

        if port_is_available(options['host'], options['port']):
            # Make a final check that the port is free.  This is needed in case someone downloaded
            #  and started another copy of KA Lite, and ran it with the default settings
            #  (port 8008, taken by Nginx), then it would kill the other server without
            # freeing up the port, so we need to raise an exception.
            pass
        else:
            raise Exception("Port %s is currently in use by another process, cannot continue" % options['port'])

    if "stop" in options:
        #we are done, get out
        return True

    cherrypyserver.run_cherrypy_server(**options)
Пример #2
0
def runcherrypyserver(argset=[], **kwargs):
    # Get the options
    options = CPWSGI_OPTIONS.copy()
    options.update(kwargs)
    for x in argset:
        if "=" in x:
            k, v = x.split('=', 1)
        else:
            k, v = x, True
        if v=='False' or v=='false':
            v = False
        options[k.lower()] = v

    if "help" in options:
        print CPWSGI_HELP
        return

    if "stop" in options:
        if options['pidfile']:
            stop_server(options['pidfile'])
            return True
        if options['host'] and options['port']:
            #fall through into the following host/port shutdown sequence
            pass
        else:
            raise Exception("must have pidfile or host+port")

    if port_is_available(options['host'], options['port']):
        pass
    else:
        # is kalite running on that port?
        existing_server_pid = ka_lite_is_using_port(options['host'], options['port'])
        if existing_server_pid:
            stop_server_using_pid(existing_server_pid)
            # try again, is kalite still running on that port?
            time.sleep(5.0)
            existing_server_pid = ka_lite_is_using_port(options['host'], options['port'])
            if existing_server_pid:
                raise Exception("Existing kalite process cannot be stopped")
        else:
            raise Exception("Port %s is currently in use by another process, cannot continue" % options['port'])

        if port_is_available(options['host'], options['port']):
            # Make a final check that the port is free.  This is needed in case someone downloaded
            #  and started another copy of KA Lite, and ran it with the default settings
            #  (port 8008, taken by Nginx), then it would kill the other server without
            # freeing up the port, so we need to raise an exception.
            pass
        else:
            raise Exception("Port %s is currently in use by another process, cannot continue" % options['port'])

    if "stop" in options:
        #we are done, get out
        return True

    cherrypyserver.run_cherrypy_server(**options)
Пример #3
0
def runcherrypyserver(argset=[], **kwargs):
    # Get the options
    options = CPWSGI_OPTIONS.copy()
    options.update(kwargs)
    for x in argset:
        if "=" in x:
            k, v = x.split('=', 1)
        else:
            k, v = x, True
        if v=='False' or v=='false':
            v = False
        options[k.lower()] = v
        
    if "help" in options:
        print CPWSGI_HELP
        return
        
    if "stop" in options:
        stop_server(options['pidfile'])
        return True
    
    cherrypyserver.run_cherrypy_server(**options)