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

    logging.getLogger('main').warning("")
    logging.getLogger('main').warning("-----------------------------------------------")
    logging.getLogger('main').warning("Starting PULI server on port:%d.", settings.PORT)
    logging.getLogger('main').warning("-----------------------------------------------")
    logging.getLogger('main').warning(" version = %s" % settings.VERSION)
    logging.getLogger('main').warning(" command = %s" % " ".join(sys.argv))
    logging.getLogger('main').warning("  daemon = %r" % options.DAEMONIZE)
    logging.getLogger('main').warning(" console = %r" % options.CONSOLE)
    logging.getLogger('main').warning(settings.PORT % "    port = %s")
    logging.getLogger('main').warning("--")

    if options.DAEMONIZE:
        logging.getLogger('main').warning("make current process a daemon and redirecting stdout/stderr to logfile")
        daemonize(settings.RUN_AS)

        try:
            # Redirect stdout and stderr to log file (using the first handler set in logging)
            sys.stdout = logging.getLogger().handlers[0].stream
            sys.stderr = logging.getLogger().handlers[0].stream
        except Exception:
            logging.getLogger('main').error("Unexpected error occured when redirecting stdout/stderr to logfile")

    logging.getLogger('main').warning("creating dispatcher main application")
    server = make_dispatcher()

    # Define a periodic callback to process DB/COMPLETION/ASSIGNMENT updates
    periodic = tornado.ioloop.PeriodicCallback(server.loop, singletonconfig.get('CORE', 'MASTER_UPDATE_INTERVAL'))
    periodic.start()
    try:
        logging.getLogger('main').warning("starting tornado main loop")
        tornado.ioloop.IOLoop.instance().start()
    except (KeyboardInterrupt, SystemExit):
        server.application.shutdown()

    # If restart flag is set (via /restart webservice)
    if server.application.restartService:
        logging.getLogger('main').warning("Restarting service...")

        try:
            # Restart server using a specific command
            subprocess.check_call(settings.RESTART_COMMAND.split())
        except subprocess.CalledProcessError, e:
            logging.getLogger('main').warning("Impossible to restart systemd unit (error: %s)" % e)
        except AttributeError, e:
            logging.getLogger('main').warning("Dispatcher settings do not define: RESTART_COMMAND")

    logging.getLogger('main').warning("Bye.")
dataset/ETHPy150Open mikrosimage/OpenRenderManagement/src/octopus/dispatcherd.py/main/swapped operands of `%`