def main():
    options = process_args()
    setup_logging(options)

    logging.getLogger('daemon').info("")
    logging.getLogger('daemon').info("-----------------------------------------------")
    logging.getLogger('daemon').info("Starting worker on %s:%d.", settings.ADDRESS, settings.PORT)
    logging.getLogger('daemon').info("-----------------------------------------------")
    logging.getLogger('daemon').info(" version = %s" % settings.VERSION)
    logging.getLogger('daemon').info(" command = %s" % " ".join(sys.argv))
    logging.getLogger('daemon').info("  daemon = %r" % options.DAEMONIZE)
    logging.getLogger('daemon').info(" console = %r" % options.CONSOLE)
    logging.getLogger('daemon').info("  server = %s:%s" % (settings.DISPATCHER_ADDRESS, settings.DISPATCHER_PORT))

    workerApplication = make_worker()
    if options.DAEMONIZE:
        daemonize(settings.RUN_AS)

    workerApplication.mainLoop()

    # After worker webservice and application is stopped, check if a restart is scheduled
    if workerApplication.application.toberestarted:
        try:
            # Restart worker using a specific command
            logging.getLogger('worker').warning("Restarting worker with command: %s" % settings.RESTART_COMMAND)
            subprocess.check_call(settings.RESTART_COMMAND.split())
        except subprocess.CalledProcessError, e:
            logging.getLogger('worker').warning("Impossible to restart systemd unit (error: %s)" % e)
        except AttributeError, e:
            logging.getLogger('worker').warning("Worker settings do not define: RESTART_COMMAND")
Beispiel #2
0
def main():
    options = process_args()
    setup_logging(options)

    logging.getLogger('daemon').info("")
    logging.getLogger('daemon').info(
        "-----------------------------------------------")
    logging.getLogger('daemon').info("Starting worker on %s:%d.",
                                     settings.ADDRESS, settings.PORT)
    logging.getLogger('daemon').info(
        "-----------------------------------------------")
    logging.getLogger('daemon').info(" version = %s" % settings.VERSION)
    logging.getLogger('daemon').info(" command = %s" % " ".join(sys.argv))
    logging.getLogger('daemon').info("  daemon = %r" % options.DAEMONIZE)
    logging.getLogger('daemon').info(" console = %r" % options.CONSOLE)
    logging.getLogger('daemon').info(
        "  server = %s:%s" %
        (settings.DISPATCHER_ADDRESS, settings.DISPATCHER_PORT))

    workerApplication = make_worker()
    if options.DAEMONIZE:
        daemonize(settings.RUN_AS)

    workerApplication.mainLoop()
    logging.getLogger('worker').warning("Bye")
def main():
    options = process_args()
    setup_logging(options)
    workerApplication = make_worker()
    if options.DAEMONIZE:
        daemonize(settings.RUN_AS)
    workerApplication.mainLoop()
def main():
    options = process_args()
    setup_logging(options)

    logging.getLogger('daemon').info( "" )
    logging.getLogger('daemon').info( "-----------------------------------------------" )
    logging.getLogger('daemon').info( "Starting worker on %s:%d.", settings.ADDRESS, settings.PORT)
    logging.getLogger('daemon').info( "-----------------------------------------------" )
    logging.getLogger('daemon').info( " version = %s" % settings.VERSION )
    logging.getLogger('daemon').info( " command = %s" % " ".join(sys.argv) )
    logging.getLogger('daemon').info( "  daemon = %r" % options.DAEMONIZE )
    logging.getLogger('daemon').info( " console = %r" % options.CONSOLE )
    logging.getLogger('daemon').info( "  server = %s:%s" % (settings.DISPATCHER_ADDRESS, settings.DISPATCHER_PORT) )
    
    workerApplication = make_worker()
    if options.DAEMONIZE:
        daemonize(settings.RUN_AS)
    workerApplication.mainLoop()