Esempio n. 1
0
def daemonize(http_server):
  pidfile_path = options.pidfile % options.port
  pid.check(pidfile_path)
  log = log_file_handler()
  daemon_context = daemon.DaemonContext(stdout=log, stderr=log, working_directory='.')
  with daemon_context:
    pid.write(pidfile_path)

    # initialize the application
    http_server.listen(options.port)

    try:
      # enter the Tornado IO loop
        tornado.ioloop.IOLoop.instance().start()
    finally:
      # ensure we remove the pidfile
        pid.remove(pidfile_path)
Esempio n. 2
0
def start_as_daemon() :
    import daemon
    import pid
    log_file = 'tornado.%s.log' % options.port
    log = open(os.path.join(Settings.LOG_PATH, log_file), 'a+')
    pidfile_path = os.path.join(Settings.PIDFILE_PATH, '%d.pid' % options.port)
    pid.check(pidfile_path)
    with daemon.DaemonContext(stdout=log, stderr=log, working_directory='.') :
        pid.write(pidfile_path)
        try :
            start()
        except Exception as err :
            Settings.logging.exception("Main ioloop exception, removing pid")
            Settings.logging.exception("Exited from: %s" % err)
            Settings.logging.exception(traceback.format_exc())
            Settings.logging.info(" * * * EXITING DUE TO ERROR * * * ")
        else :
            Settings.logging.info(" * * * EXITING NORMALLY * * * ")
        pid.remove(pidfile_path)
Esempio n. 3
0
def start_as_daemon():
    import daemon
    import pid

    log_file = "tornado.%s.log" % options.port
    log = open(os.path.join(Settings.LOG_PATH, log_file), "a+")
    pidfile_path = os.path.join(Settings.PIDFILE_PATH, "%d.pid" % options.port)
    pid.check(pidfile_path)
    with daemon.DaemonContext(stdout=log, stderr=log, working_directory="."):
        pid.write(pidfile_path)
        try:
            start()
        except Exception as err:
            Settings.logging.exception("Main ioloop exception, removing pid")
            Settings.logging.exception("Exited from: %s" % err)
            Settings.logging.exception(traceback.format_exc())
            Settings.logging.info(" * * * EXITING DUE TO ERROR * * * ")
        else:
            Settings.logging.info(" * * * EXITING NORMALLY * * * ")
        pid.remove(pidfile_path)