示例#1
0
def main():
    # Read the arguments
    try:
        scgi_port = int(sys.argv[1])
        cfg_file  = sys.argv[2]
    except:
        print "Incorrect parameters: PORT CONFIG_FILE"
        raise SystemExit

    # Try to avoid zombie processes 
    if hasattr(signal, "SIGCHLD"):
        signal.signal(signal.SIGCHLD, signal.SIG_IGN)

    # Move to the server directory
    pathname, scriptname = os.path.split(sys.argv[0])
    os.chdir(os.path.abspath(pathname))

    # SCGI server
    srv = pyscgi.ServerFactory (True, handler_class=Handler, host="127.0.0.1", port=scgi_port)
    srv.socket.settimeout (MODIFIED_CHECK_ELAPSE)

    # Read configuration file
    global cfg
    cfg = Config(cfg_file)
    
    print ("Server %s running.. PID=%d Port=%d" % (VERSION, os.getpid(), scgi_port))

    # Iterate until the user exists
    try:
        while True:
            srv.handle_request()
    except KeyboardInterrupt:
        print "\rServer exiting.."

    srv.server_close()
示例#2
0
    def init_server(self, *args, **kwargs):
        # Is it already init?
        if self._is_init:
            return
        self._is_init = True

        # Instance SCGI server
        self._scgi = pyscgi.ServerFactory(*args, **kwargs)
示例#3
0
    def init_server(self, *args, **kwargs):
        # Is it already init?
        if self._is_init:
            return
        self._is_init = True

        # Security cookie/submit
        if 'sec_cookie' in kwargs:
            self.use_sec_cookie = kwargs.pop('sec_cookie')

        if 'sec_submit' in kwargs:
            self.use_sec_submit = kwargs.pop('sec_submit')

        # Instance SCGI server
        self._scgi = pyscgi.ServerFactory(*args, **kwargs)

        # Figure plug-in paths
        from Plugin import figure_plugin_paths
        self.plugin_paths = figure_plugin_paths()