def main(): parser = argparse.ArgumentParser(description='Run the Web Console') parser.add_argument('--fd', help='FD', default=None) parser.add_argument('--host', help='Host', default='0.0.0.0') parser.add_argument('--port', help='port', default=8080) parser.add_argument('--server', help='web server to use', default=SocketIOServer) parser.add_argument('--endpoint', default=None, help='Circus Endpoint. If not specified, Circus will ask you which ' 'system you want to connect to') parser.add_argument('--version', action='store_true', default=False, help='Displays Circus version and exits.') parser.add_argument('--log-level', dest='loglevel', default='info', choices=LOG_LEVELS.keys() + [key.upper() for key in LOG_LEVELS.keys()], help="log level") parser.add_argument('--log-output', dest='logoutput', default='-', help="log output") parser.add_argument('--ssh', default=None, help='SSH Server') args = parser.parse_args() if args.version: print(__version__) sys.exit(0) # configure the logger configure_logger(logger, args.loglevel, args.logoutput) if args.endpoint is not None: connect_to_circus(args.endpoint, args.ssh) run(app, host=args.host, port=args.port, server=args.server, fd=args.fd)
def main(): parser = argparse.ArgumentParser(description='Run the Web Console') parser.add_argument('--fd', help='FD', default=None) parser.add_argument('--host', help='Host', default='0.0.0.0') parser.add_argument('--port', help='port', default=8080) parser.add_argument('--server', help='web server to use', default=SocketIOServer) parser.add_argument('--endpoint', default=None, help='Circus Endpoint. If not specified, Circus will ' 'ask you which system you want to connect to') parser.add_argument('--version', action='store_true', default=False, help='Displays Circus version and exits.') parser.add_argument('--log-level', dest='loglevel', default='info', choices=LOG_LEVELS.keys() + [key.upper() for key in LOG_LEVELS.keys()], help="log level") parser.add_argument('--log-output', dest='logoutput', default='-', help="log output") parser.add_argument('--ssh', default=None, help='SSH Server') parser.add_argument('--multicast', dest="multicast", default="udp://237.219.251.97:12027", help="Multicast endpoint. If not specified, Circus " "will use default one") args = parser.parse_args() if args.version: print(__version__) sys.exit(0) # configure the logger configure_logger(logger, args.loglevel, args.logoutput) if args.endpoint is not None: connect_to_circus(args.endpoint, args.ssh) try: sys.stderr.write(' ') quiet = False except IOError: quiet = True setup_auto_discovery(args.multicast) run(app, host=args.host, port=args.port, server=args.server, fd=args.fd, quiet=quiet)
def main(): parser = argparse.ArgumentParser(description='Run some watchers.') parser.add_argument('config', help='configuration file', nargs='?') # XXX we should be able to add all these options in the config file as well parser.add_argument('--log-level', dest='loglevel', choices=LOG_LEVELS.keys() + [key.upper() for key in LOG_LEVELS.keys()], help="log level") parser.add_argument( '--log-output', dest='logoutput', help=( "The location where the logs will be written. The default behavior " "is to write to stdout (you can force it by passing '-' to " "this option). Takes a filename otherwise.")) parser.add_argument('--daemon', dest='daemonize', action='store_true', help="Start circusd in the background") parser.add_argument('--pidfile', dest='pidfile') parser.add_argument('--version', action='store_true', default=False, help='Displays Circus version and exits.') args = parser.parse_args() if args.version: print(__version__) sys.exit(0) if args.config is None: parser.print_usage() sys.exit(0) if args.daemonize: daemonize() # basic logging configuration logging.basicConfig() # From here it can also come from the arbiter configuration # load the arbiter from config arbiter = Arbiter.load_from_config(args.config) pidfile = args.pidfile or arbiter.pidfile or None if pidfile: pidfile = Pidfile(pidfile) try: pidfile.create(os.getpid()) except RuntimeError, e: print(str(e)) sys.exit(1)
def main(): define("port", default=8080, type=int) parser = argparse.ArgumentParser(description='Run the Web Console') parser.add_argument('--fd', help='FD', default=None, type=int) parser.add_argument('--host', help='Host', default='0.0.0.0') parser.add_argument('--port', help='port', default=8080) parser.add_argument('--endpoint', default=None, help='Circus Endpoint. If not specified, Circus will ' 'ask you which system you want to connect to') parser.add_argument('--version', action='store_true', default=False, help='Displays Circus version and exits.') parser.add_argument('--log-level', dest='loglevel', default='info', choices=LOG_LEVELS.keys() + [key.upper() for key in LOG_LEVELS.keys()], help="log level") parser.add_argument('--log-output', dest='logoutput', default='-', help="log output") parser.add_argument('--ssh', default=None, help='SSH Server') parser.add_argument('--multicast', dest="multicast", default="udp://237.219.251.97:12027", help="Multicast endpoint. If not specified, Circus " "will use default one") args = parser.parse_args() if args.version: print(__version__) sys.exit(0) # configure the logger configure_logger(logger, args.loglevel, args.logoutput) # Get the tornado ioloop singleton loop = tornado.ioloop.IOLoop.instance() if args.endpoint is not None: connect_to_circus(loop, args.endpoint, args.ssh) app.auto_discovery = AutoDiscovery(args.multicast, loop) http_server = tornado.httpserver.HTTPServer(app) if args.fd: sock = socket.fromfd(args.fd, socket.AF_INET, socket.SOCK_STREAM) sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) sock.setblocking(0) http_server.add_sockets([sock]) logger.info("Starting circus web ui on fd %d" % args.fd) else: http_server.listen(args.port, args.host) logger.info("Starting circus web ui on %s:%s" % (args.host, args.port)) loop.start()
def main(): parser = argparse.ArgumentParser(description='Run some watchers.') parser.add_argument('config', help='configuration file', nargs='?') # XXX we should be able to add all these options in the config file as well parser.add_argument('--log-level', dest='loglevel', choices=LOG_LEVELS.keys() + [key.upper() for key in LOG_LEVELS.keys()], help="log level") parser.add_argument('--log-output', dest='logoutput', help=( "The location where the logs will be written. The default behavior " "is to write to stdout (you can force it by passing '-' to " "this option). Takes a filename otherwise.")) parser.add_argument('--daemon', dest='daemonize', action='store_true', help="Start circusd in the background") parser.add_argument('--pidfile', dest='pidfile') parser.add_argument('--version', action='store_true', default=False, help='Displays Circus version and exits.') args = parser.parse_args() if args.version: print(__version__) sys.exit(0) if args.config is None: parser.print_usage() sys.exit(0) if args.daemonize: daemonize() # basic logging configuration logging.basicConfig() # From here it can also come from the arbiter configuration # load the arbiter from config arbiter = Arbiter.load_from_config(args.config) pidfile = args.pidfile or arbiter.pidfile or None if pidfile: pidfile = Pidfile(pidfile) try: pidfile.create(os.getpid()) except RuntimeError, e: print(str(e)) sys.exit(1)
def main(): parser = argparse.ArgumentParser(description="Run some watchers.") parser.add_argument("config", help="configuration file", nargs="?") # XXX we should be able to add all these options in the config file as well parser.add_argument( "--log-level", dest="loglevel", default="info", choices=LOG_LEVELS.keys() + [key.upper() for key in LOG_LEVELS.keys()], help="log level", ) parser.add_argument( "--log-output", dest="logoutput", default="-", help=( "The location where the logs will be written. The default behavior " "is to write to stdout (you can force it by passing '-' to " "this option). Takes a filename otherwise." ), ) parser.add_argument("--daemon", dest="daemonize", action="store_true", help="Start circusd in the background") parser.add_argument("--pidfile", dest="pidfile") parser.add_argument("--version", action="store_true", default=False, help="Displays Circus version and exits.") args = parser.parse_args() if args.version: print(__version__) sys.exit(0) if args.config is None: parser.print_usage() sys.exit(0) if args.daemonize: daemonize() pidfile = None if args.pidfile: pidfile = Pidfile(args.pidfile) try: pidfile.create(os.getpid()) except RuntimeError, e: print(str(e)) sys.exit(1)
def main(): parser = argparse.ArgumentParser(description='Run some watchers.') parser.add_argument('config', help='configuration file', nargs='?') # XXX we should be able to add all these options in the config file as well parser.add_argument('--log-level', dest='loglevel', default='info', choices=LOG_LEVELS.keys() + [key.upper() for key in LOG_LEVELS.keys()], help="log level") parser.add_argument('--log-output', dest='logoutput', default='-', help="log output") parser.add_argument('--daemon', dest='daemonize', action='store_true', help="Start circusd in the background") parser.add_argument('--pidfile', dest='pidfile') parser.add_argument('--version', action='store_true', default=False, help='Displays Circus version and exits.') args = parser.parse_args() if args.version: print(__version__) sys.exit(0) if args.config is None: parser.print_usage() sys.exit(0) if args.daemonize: daemonize() pidfile = None if args.pidfile: pidfile = Pidfile(args.pidfile) try: pidfile.create(os.getpid()) except RuntimeError, e: print(str(e)) sys.exit(1)
def main(): import zmq try: zmq_version = [int(part) for part in zmq.__version__.split('.')] if len(zmq_version) < 2: raise ValueError() except (AttributeError, ValueError): print('Unknown PyZQM version - aborting...') sys.exit(0) if zmq_version[0] < 13 or (zmq_version[0] == 13 and zmq_version[1] < 1): print('circusd needs PyZMQ >= 13.1.0 to run - aborting...') sys.exit(0) parser = argparse.ArgumentParser(description='Run some watchers.') parser.add_argument('config', help='configuration file', nargs='?') # XXX we should be able to add all these options in the config file as well parser.add_argument('--log-level', dest='loglevel', choices=list(LOG_LEVELS.keys()) + [key.upper() for key in LOG_LEVELS.keys()], help="log level") parser.add_argument( '--log-output', dest='logoutput', help=( "The location where the logs will be written. The default behavior " "is to write to stdout (you can force it by passing '-' to " "this option). Takes a filename otherwise.")) parser.add_argument( "--logger-config", dest="loggerconfig", help=("The location where a standard Python logger configuration INI, " "JSON or YAML file can be found. This can be used to override " "the default logging configuration for the arbiter.")) parser.add_argument('--daemon', dest='daemonize', action='store_true', help="Start circusd in the background") parser.add_argument('--pidfile', dest='pidfile') parser.add_argument('--version', action='store_true', default=False, help='Displays Circus version and exits.') args = parser.parse_args() if args.version: print(__version__) sys.exit(0) if args.config is None: parser.print_usage() sys.exit(0) if args.daemonize: daemonize() # From here it can also come from the arbiter configuration # load the arbiter from config arbiter = Arbiter.load_from_config(args.config) # go ahead and set umask early if it is in the config if arbiter.umask is not None: os.umask(arbiter.umask) pidfile = args.pidfile or arbiter.pidfile or None if pidfile: pidfile = Pidfile(pidfile) try: pidfile.create(os.getpid()) except RuntimeError as e: print(str(e)) sys.exit(1) # configure the logger loglevel = args.loglevel or arbiter.loglevel or 'info' logoutput = args.logoutput or arbiter.logoutput or '-' loggerconfig = args.loggerconfig or arbiter.loggerconfig or None configure_logger(logger, loglevel, logoutput, loggerconfig) # Main loop restart = True while restart: try: arbiter = arbiter or Arbiter.load_from_config(args.config) future = arbiter.start() restart = False if check_future_exception_and_log(future) is None: restart = arbiter._restarting except Exception as e: # emergency stop arbiter.loop.run_sync(arbiter._emergency_stop) raise (e) except KeyboardInterrupt: pass finally: arbiter = None if pidfile is not None: pidfile.unlink() sys.exit(0)
def main(): import zmq try: zmq_version = [int(part) for part in zmq.__version__.split('.')] if len(zmq_version) < 2: raise ValueError() except (AttributeError, ValueError): print('Unknown PyZQM version - aborting...') sys.exit(0) if zmq_version[0] < 13 or (zmq_version[0] == 13 and zmq_version[1] < 1): print('circusd needs PyZMQ >= 13.1.0 to run - aborting...') sys.exit(0) parser = argparse.ArgumentParser(description='Run some watchers.') parser.add_argument('config', help='configuration file', nargs='?') # XXX we should be able to add all these options in the config file as well parser.add_argument('--log-level', dest='loglevel', choices=list(LOG_LEVELS.keys()) + [ key.upper() for key in LOG_LEVELS.keys()], help="log level") parser.add_argument('--log-output', dest='logoutput', help=( "The location where the logs will be written. The default behavior " "is to write to stdout (you can force it by passing '-' to " "this option). Takes a filename otherwise.")) parser.add_argument('--daemon', dest='daemonize', action='store_true', help="Start circusd in the background") parser.add_argument('--pidfile', dest='pidfile') parser.add_argument('--version', action='store_true', default=False, help='Displays Circus version and exits.') args = parser.parse_args() if args.version: print(__version__) sys.exit(0) if args.config is None: parser.print_usage() sys.exit(0) if args.daemonize: daemonize() # This config call is done to avoid any # "no handlers could be found for logger" # # error while loding the configuration and setting up the arbiter. # The real logging configuration is done right after via # a configure_logger() call logging.basicConfig() # From here it can also come from the arbiter configuration # load the arbiter from config arbiter = Arbiter.load_from_config(args.config) # go ahead and set umask early if it is in the config if arbiter.umask is not None: os.umask(arbiter.umask) pidfile = args.pidfile or arbiter.pidfile or None if pidfile: pidfile = Pidfile(pidfile) try: pidfile.create(os.getpid()) except RuntimeError as e: print(str(e)) sys.exit(1) # configure the logger loglevel = args.loglevel or arbiter.loglevel or 'info' logoutput = args.logoutput or arbiter.logoutput or '-' configure_logger(logger, loglevel, logoutput) # Main loop restart = True while restart: try: arbiter = arbiter or Arbiter.load_from_config(args.config) future = arbiter.start() restart = False if check_future_exception_and_log(future) is None: restart = arbiter._restarting except Exception as e: # emergency stop arbiter.loop.run_sync(arbiter._emergency_stop) raise(e) except KeyboardInterrupt: pass finally: arbiter = None if pidfile is not None: pidfile.unlink() sys.exit(0)
def main(): parser = argparse.ArgumentParser(description='Run some watchers.') parser.add_argument('config', help='configuration file', nargs='?') # XXX we should be able to add all these options in the config file as well parser.add_argument('--log-level', dest='loglevel', choices=list(LOG_LEVELS.keys()) + [ key.upper() for key in LOG_LEVELS.keys()], help="log level") parser.add_argument('--log-output', dest='logoutput', help=( "The location where the logs will be written. The default behavior " "is to write to stdout (you can force it by passing '-' to " "this option). Takes a filename otherwise.")) parser.add_argument('--daemon', dest='daemonize', action='store_true', help="Start circusd in the background") parser.add_argument('--pidfile', dest='pidfile') parser.add_argument('--version', action='store_true', default=False, help='Displays Circus version and exits.') args = parser.parse_args() if args.version: print(__version__) sys.exit(0) if args.config is None: parser.print_usage() sys.exit(0) if args.daemonize: daemonize() # basic logging configuration logging.basicConfig() # From here it can also come from the arbiter configuration # load the arbiter from config arbiter = Arbiter.load_from_config(args.config) pidfile = args.pidfile or arbiter.pidfile or None if pidfile: pidfile = Pidfile(pidfile) try: pidfile.create(os.getpid()) except RuntimeError as e: print(str(e)) sys.exit(1) # configure the logger loglevel = args.loglevel or arbiter.loglevel or 'info' logoutput = args.logoutput or arbiter.logoutput or '-' configure_logger(logger, loglevel, logoutput) # configure the main loop #ioloop.install() #loop = ioloop.IOLoop.instance() #cb = functools.partial(manage_restart, loop, arbiter) #periodic = tornado.ioloop.PeriodicCallback(cb, 1000, loop) #periodic.start() # schedule the arbiter start #arbiter = Arbiter.load_from_config(args.config, loop=loop) #loop.add_future(arbiter.start(), _arbiter_start_cb) # Main loop restart = True while restart: try: arbiter = Arbiter.load_from_config(args.config) future = arbiter.start() restart = False if check_future_exception_and_log(future) is None: restart = arbiter._restarting except Exception as e: # emergency stop arbiter.loop.run_sync(arbiter._emergency_stop) raise(e) except KeyboardInterrupt: pass finally: if pidfile is not None: pidfile.unlink() sys.exit(0)
def main(): import zmq try: zmq_version = [int(part) for part in zmq.__version__.split(".")] if len(zmq_version) < 2: raise ValueError() except (AttributeError, ValueError): print("Unknown PyZQM version - aborting...") sys.exit(0) if zmq_version[0] < 13 or (zmq_version[0] == 13 and zmq_version[1] < 1): print("circusd needs PyZMQ >= 13.1.0 to run - aborting...") sys.exit(0) parser = argparse.ArgumentParser(description="Run some watchers.") parser.add_argument("config", help="configuration file", nargs="?") # XXX we should be able to add all these options in the config file as well parser.add_argument( "--log-level", dest="loglevel", choices=list(LOG_LEVELS.keys()) + [key.upper() for key in LOG_LEVELS.keys()], help="log level", ) parser.add_argument( "--log-output", dest="logoutput", help=( "The location where the logs will be written. The default behavior " "is to write to stdout (you can force it by passing '-' to " "this option). Takes a filename otherwise." ), ) parser.add_argument( "--logger-config", dest="loggerconfig", help=( "The location where a standard Python logger configuration INI, " "JSON or YAML file can be found. This can be used to override " "the default logging configuration for the arbiter." ), ) parser.add_argument("--daemon", dest="daemonize", action="store_true", help="Start circusd in the background") parser.add_argument("--pidfile", dest="pidfile") parser.add_argument("--version", action="store_true", default=False, help="Displays Circus version and exits.") args = parser.parse_args() if args.version: print(__version__) sys.exit(0) if args.config is None: parser.print_usage() sys.exit(0) if args.daemonize: daemonize() # From here it can also come from the arbiter configuration # load the arbiter from config arbiter = Arbiter.load_from_config(args.config) # go ahead and set umask early if it is in the config if arbiter.umask is not None: os.umask(arbiter.umask) pidfile = args.pidfile or arbiter.pidfile or None if pidfile: pidfile = Pidfile(pidfile) try: pidfile.create(os.getpid()) except RuntimeError as e: print(str(e)) sys.exit(1) # configure the logger loglevel = args.loglevel or arbiter.loglevel or "info" logoutput = args.logoutput or arbiter.logoutput or "-" loggerconfig = args.loggerconfig or arbiter.loggerconfig or None configure_logger(logger, loglevel, logoutput, loggerconfig) # Main loop restart = True while restart: try: arbiter = arbiter or Arbiter.load_from_config(args.config) future = arbiter.start() restart = False if check_future_exception_and_log(future) is None: restart = arbiter._restarting except Exception as e: # emergency stop arbiter.loop.run_sync(arbiter._emergency_stop) raise (e) except KeyboardInterrupt: pass finally: arbiter = None if pidfile is not None: pidfile.unlink() sys.exit(0)
def main(): define("port", default=8080, type=int) parser = argparse.ArgumentParser(description='Run the Web Console') parser.add_argument('--fd', help='FD', default=None, type=int) parser.add_argument('--host', help='Host', default='0.0.0.0') parser.add_argument('--port', help='port', default=8080) parser.add_argument('--endpoint', default=None, help='Circus Endpoint. If not specified, Circus will ' 'ask you which system you want to connect to') parser.add_argument('--version', action='store_true', default=False, help='Displays Circus version and exits.') parser.add_argument('--log-level', dest='loglevel', default='info', choices=list(LOG_LEVELS.keys()) + [key.upper() for key in LOG_LEVELS.keys()], help="log level") parser.add_argument('--log-output', dest='logoutput', default='-', help="log output") parser.add_argument('--ssh', default=None, help='SSH Server') parser.add_argument('--multicast', dest="multicast", default="udp://237.219.251.97:12027", help="Multicast endpoint. If not specified, Circus " "will use default one") args = parser.parse_args() if args.version: print(__version__) sys.exit(0) # configure the logger configure_logger(logger, args.loglevel, args.logoutput) # Get the tornado ioloop singleton loop = tornado.ioloop.IOLoop.instance() if args.endpoint is not None: connect_to_circus(loop, args.endpoint, args.ssh) app.auto_discovery = AutoDiscovery(args.multicast, loop) http_server = tornado.httpserver.HTTPServer(app, xheaders=True) if args.fd: sock = socket.fromfd(args.fd, socket.AF_INET, socket.SOCK_STREAM) sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) sock.setblocking(0) http_server.add_sockets([sock]) logger.info("Starting circus web ui on fd %d" % args.fd) else: http_server.listen(args.port, args.host) logger.info("Starting circus web ui on %s:%s" % (args.host, args.port)) loop.start()
def main(): parser = argparse.ArgumentParser(description='Run some watchers.') parser.add_argument('config', help='configuration file', nargs='?') # XXX we should be able to add all these options in the config file as well parser.add_argument('--log-level', dest='loglevel', choices=list(LOG_LEVELS.keys()) + [key.upper() for key in LOG_LEVELS.keys()], help="log level") parser.add_argument( '--log-output', dest='logoutput', help=( "The location where the logs will be written. The default behavior " "is to write to stdout (you can force it by passing '-' to " "this option). Takes a filename otherwise.")) parser.add_argument('--daemon', dest='daemonize', action='store_true', help="Start circusd in the background") parser.add_argument('--pidfile', dest='pidfile') parser.add_argument('--version', action='store_true', default=False, help='Displays Circus version and exits.') args = parser.parse_args() if args.version: print(__version__) sys.exit(0) if args.config is None: parser.print_usage() sys.exit(0) if args.daemonize: daemonize() # basic logging configuration logging.basicConfig() # From here it can also come from the arbiter configuration # load the arbiter from config arbiter = Arbiter.load_from_config(args.config) pidfile = args.pidfile or arbiter.pidfile or None if pidfile: pidfile = Pidfile(pidfile) try: pidfile.create(os.getpid()) except RuntimeError as e: print(str(e)) sys.exit(1) # configure the logger loglevel = args.loglevel or arbiter.loglevel or 'info' logoutput = args.logoutput or arbiter.logoutput or '-' configure_logger(logger, loglevel, logoutput) # configure the main loop #ioloop.install() #loop = ioloop.IOLoop.instance() #cb = functools.partial(manage_restart, loop, arbiter) #periodic = tornado.ioloop.PeriodicCallback(cb, 1000, loop) #periodic.start() # schedule the arbiter start #arbiter = Arbiter.load_from_config(args.config, loop=loop) #loop.add_future(arbiter.start(), _arbiter_start_cb) # Main loop restart = True while restart: try: arbiter = Arbiter.load_from_config(args.config) future = arbiter.start() restart = False if check_future_exception_and_log(future) is None: restart = arbiter._restarting except Exception as e: # emergency stop arbiter.loop.run_sync(arbiter._emergency_stop) raise (e) except KeyboardInterrupt: pass finally: if pidfile is not None: pidfile.unlink() sys.exit(0)