예제 #1
0
파일: server.py 프로젝트: giann/crawl
    shed_privileges()

    if dgl_mode:
        userdb.ensure_user_db_exists()
    userdb.ensure_settings_db_exists()

    ioloop = tornado.ioloop.IOLoop.instance()
    ioloop.set_blocking_log_threshold(0.5)

    if dgl_mode:
        status_file_timeout()
        purge_login_tokens_timeout()
        start_reading_milestones()

        if watch_socket_dirs:
            process_handler.watch_socket_dirs()

    logging.info("Webtiles server started! (PID: %s)" % os.getpid())

    try:
        ioloop.start()
    except KeyboardInterrupt:
        logging.info("Received keyboard interrupt, shutting down.")
        for server in servers: server.stop()
        shutdown()
        ioloop.add_timeout(time.time() + 2, ioloop.stop)
        if len(sockets) > 0:
            ioloop.start() # We'll wait until all crawl processes have ended.

    remove_pidfile()
예제 #2
0
파일: server.py 프로젝트: ccanari/crawl
    ensure_tornado_current()

    shed_privileges()

    if dgl_mode:
        userdb.ensure_user_db_exists()
        userdb.upgrade_user_db()
    userdb.ensure_settings_db_exists()
    try:
        IOLoop.current().set_blocking_log_threshold(0.5)  # type: ignore
        logging.info("Blocking call timeout: 500ms.")
    except:
        # this is the new normal; still not sure of a way to deal with this.
        logging.info("Webserver running without a blocking call timeout.")

    if dgl_mode:
        status_file_timeout()
        auth.purge_login_tokens_timeout()
        start_reading_milestones()

        if watch_socket_dirs:
            process_handler.watch_socket_dirs()

    logging.info("DCSS Webtiles server started with Tornado %s! (PID: %s)" %
                 (tornado.version, os.getpid()))

    IOLoop.current().start()

    logging.info("Bye!")
    remove_pidfile()
예제 #3
0
def server_main():
    args = parse_args()
    if config.chroot:
        os.chroot(config.chroot)

    if getattr(config, 'live_debug', False):
        logging.info("Starting in live-debug mode.")
        config.watch_socket_dirs = False

    # do this here so it can happen before logging init
    if args.logfile:
        if args.logfile == "-":
            config.logging_config.pop('filename', None)
            args.logfile = "<stdout>"  # make the log message easier to read
        else:
            config.logging_config['filename'] = args.logfile

    init_logging(config.logging_config)

    if args.logfile:
        logging.info("Using command-line supplied logfile: '%s'", args.logfile)

    _do_load_games()

    export_args_to_config(args)

    if not check_config():
        err_exit("Errors in config. Exiting.")

    if config.daemon:
        daemonize()

    signal.signal(signal.SIGTERM, signal_handler)
    signal.signal(signal.SIGHUP, signal_handler)
    signal.signal(signal.SIGINT, signal_handler)

    if getattr(config, 'umask', None) is not None:
        os.umask(config.umask)

    write_pidfile()

    global servers
    servers = bind_server()
    ensure_tornado_current()

    shed_privileges()

    if config.dgl_mode:
        userdb.ensure_user_db_exists()
        userdb.upgrade_user_db()
    userdb.ensure_settings_db_exists()

    signal.signal(signal.SIGUSR1, usr1_handler)

    try:
        IOLoop.current().set_blocking_log_threshold(0.5) # type: ignore
        logging.info("Blocking call timeout: 500ms.")
    except:
        # this is the new normal; still not sure of a way to deal with this.
        logging.info("Webserver running without a blocking call timeout.")

    if config.dgl_mode:
        status_file_timeout()
        auth.purge_login_tokens_timeout()
        start_reading_milestones()

        if config.watch_socket_dirs:
            process_handler.watch_socket_dirs()

    logging.info("DCSS Webtiles server started with Tornado %s! (PID: %s)" %
                                                (tornado.version, os.getpid()))

    IOLoop.current().start()

    logging.info("Bye!")
    remove_pidfile()