Example #1
0
    def run(self):
        if self.cfg.check_config:
            try:
                self.load()
            except:
                sys.stderr.write("\nError while loading the application:\n\n")
                traceback.print_exc()
                sys.stderr.flush()
                sys.exit(1)
            sys.exit(0)

        if self.cfg.spew:
            debug.spew()
        if self.cfg.daemon:
            util.daemonize()

        # set python paths
        if self.cfg.pythonpath and self.cfg.pythonpath is not None:
            paths = self.cfg.pythonpath.split(",")
            for path in paths:
                pythonpath = os.path.abspath(self.cfg.pythonpath)
                if pythonpath not in sys.path:
                    sys.path.insert(0, pythonpath)

        try:
            Arbiter(self).run()
        except RuntimeError as e:
            sys.stderr.write("\nError: %s\n\n" % e)
            sys.stderr.flush()
            sys.exit(1)
Example #2
0
    def run(self):
        if self.cfg.check_config:
            try:
                self.load()
            except:
                msg = "\nError while loading the application:\n"
                print(msg, file=sys.stderr)
                traceback.print_exc()
                sys.stderr.flush()
                sys.exit(1)
            sys.exit(0)

        if self.cfg.spew:
            debug.spew()

        if self.cfg.daemon:
            util.daemonize(self.cfg.enable_stdio_inheritance)

        # set python paths
        if self.cfg.pythonpath:
            paths = self.cfg.pythonpath.split(",")
            for path in paths:
                pythonpath = os.path.abspath(path)
                if pythonpath not in sys.path:
                    sys.path.insert(0, pythonpath)

        super().run()
Example #3
0
    def run(self):
        if self.cfg.check_config:
            try:
                self.load()
            except:
                sys.stderr.write("\nError while loading the application:\n\n")
                traceback.print_exc()
                sys.stderr.flush()
                sys.exit(1)
            sys.exit(0)

        if self.cfg.spew:
            debug.spew()
        if self.cfg.daemon:
            util.daemonize()

        # set python paths
        if self.cfg.pythonpath and self.cfg.pythonpath is not None:
            paths = self.cfg.pythonpath.split(",")
            for path in paths:
                pythonpath = os.path.abspath(self.cfg.pythonpath)
                if pythonpath not in sys.path:
                    sys.path.insert(0, pythonpath)

        try:
            Arbiter(self).run()
        except RuntimeError as e:
            sys.stderr.write("\nError: %s\n\n" % e)
            sys.stderr.flush()
            sys.exit(1)
Example #4
0
def run(env):
    """ 웹서버를 실행한다.
    
    웹서버 환경은 dev, prod 로 구분되고 프로세스 개수는 환경에 따라 다르다.
    
    dev 모드는 무조건 1개로 고정하고 prod 모드는 settings.SERVER_PROCESS 값만큼 결정된다.
    
    """
    from pyft.app import App

    options = {
        'bind': '%s:%s' % (settings.SERVER_HOST, settings.SERVER_PORT),
        'timeout': settings.SERVER_TIMEOUT,
        'pidfile': settings.SERVER_PID_FILE,
        'loglevel': 'debug' if settings.DEBUG else 'error',
        'proc_name': settings.SERVER_PROCESS_NAME,
        'limit_request_lint': settings.LIMIT_REQUEST_LINE,
        'limit_request_fields': settings.LIMIT_REQUEST_FIELDS,
        'limit_request_field_size': settings.LIMIT_REQUEST_FIELD_SIZE,
    }

    if env == 'prod':
        util.daemonize(False)
        options['workers'] = int(settings.SERVER_PROCESS)

    App(options).run()
Example #5
0
    def run(self):
        if self.cfg.check_config:
            try:
                self.load()
            except:
                msg = "\nError while loading the application:\n"
                print(msg, file=sys.stderr)
                traceback.print_exc()
                sys.stderr.flush()
                sys.exit(1)
            sys.exit(0)

        if self.cfg.spew:
            debug.spew()

        if self.cfg.daemon:
            util.daemonize(self.cfg.enable_stdio_inheritance)

        # set python paths
        if self.cfg.pythonpath:
            paths = self.cfg.pythonpath.split(",")
            for path in paths:
                pythonpath = os.path.abspath(path)
                if pythonpath not in sys.path:
                    sys.path.insert(0, pythonpath)

        super(Application, self).run()
Example #6
0
 def run(self):
     if self.cfg.spew:
         debug.spew()
     if self.cfg.daemon:
         util.daemonize()
     else:
         os.setpgrp()
     self.configure_logging()
     Arbiter(self).run()
Example #7
0
 def run(self):
     if self.cfg.spew:
         debug.spew()
     if self.cfg.daemon:
         # daemonize should not close logfile fd, see method doc
         self.close_logfile()
         util.daemonize()
         self.configure_logging()
     else:
         os.setpgrp()
     Arbiter(self).run()
Example #8
0
 def run(self):
     if self.cfg.spew:
         debug.spew()
     if self.cfg.daemon:
         util.daemonize()
     else:
         try:
             os.setpgrp()
         except OSError, e:
             if e[0] != errno.EPERM:
                 raise
Example #9
0
 def run(self):
     if self.cfg.spew:
         debug.spew()
     if self.cfg.daemon:
         util.daemonize()
     else:
         try:
             os.setpgrp()
         except OSError, e:
             if e[0] == errno.EPERM:
                 sys.stderr.write("Error: You should use "
                     "daemon mode here.\n")
             raise
Example #10
0
    def run(self):
        if self.cfg.check_config:
            try:
                self.load()
            except Exception:
                msg = "Error while loading the application"
                sys.exit(msg)

            sys.exit(0)

        if self.cfg.spew:
            debug.spew()

        if self.cfg.daemon:
            util.daemonize(self.cfg.enable_stdio_inheritance)

        super().run()
Example #11
0
    def run(self):
        # 配置校验无误
        if self.cfg.check_config:
            try:
                # 加载配置
                self.load()
            except:
                msg = "\nError while loading the application:\n"
                print(msg, file=sys.stderr)
                # 打印异常信息
                traceback.print_exc()
                # 清空标准错误信息
                sys.stderr.flush()
                sys.exit(1)
            sys.exit(0)

        if self.cfg.spew:
            # 打开了--spew开关
            # Install a trace function that spews every line
            # executed by the server.
            debug.spew()

        if self.cfg.daemon:
            # run in daemon mode
            util.daemonize(self.cfg.enable_stdio_inheritance)

        # set python paths
        if self.cfg.pythonpath:
            paths = self.cfg.pythonpath.split(",")
            for path in paths:
                pythonpath = os.path.abspath(path)
                if pythonpath not in sys.path:
                    sys.path.insert(0, pythonpath)

        # 运行入口
        super().run()