def start(config, args): """Start Glances.""" # Load mode global mode start_duration = Counter() if core.is_standalone(): from glances.standalone import GlancesStandalone as GlancesMode elif core.is_client(): if core.is_client_browser(): from glances.client_browser import GlancesClientBrowser as GlancesMode else: from glances.client import GlancesClient as GlancesMode elif core.is_server(): from glances.server import GlancesServer as GlancesMode elif core.is_webserver(): from glances.webserver import GlancesWebServer as GlancesMode # Init the mode logger.info("Start {} mode".format(GlancesMode.__name__)) mode = GlancesMode(config=config, args=args) # Start the main loop logger.debug("Glances started in {} seconds".format(start_duration.get())) mode.serve_forever() # Shutdown mode.end()
def start(config, args): """Start Glances""" # Load mode global mode if core.is_standalone(): from glances.standalone import GlancesStandalone as GlancesMode elif core.is_client(): if core.is_client_browser(): from glances.client_browser import GlancesClientBrowser as GlancesMode else: from glances.client import GlancesClient as GlancesMode elif core.is_server(): from glances.server import GlancesServer as GlancesMode elif core.is_webserver(): from glances.webserver import GlancesWebServer as GlancesMode # Init the mode logger.info("Start {} mode".format(GlancesMode.__name__)) mode = GlancesMode(config=config, args=args) # Start the main loop mode.serve_forever() # Shutdown mode.end()
def start_standalone(config, args): """Start the standalone mode""" logger.info("Start standalone mode") # Share global var global standalone # Import the Glances standalone module from glances.standalone import GlancesStandalone # Init the standalone mode standalone = GlancesStandalone(config=config, args=args) # Start the standalone (CLI) loop standalone.serve_forever()
def main(): """Main entry point for Glances. Select the mode (standalone, client or server) Run it... """ # Log Glances and PSutil version logger.info('Start Glances {0}'.format(__version__)) logger.info('{0} {1} and PSutil {2} detected'.format( platform.python_implementation(), platform.python_version(), __psutil_version)) # Share global var global core, standalone, client, server, webserver # Create the Glances main instance core = GlancesMain() # Catch the CTRL-C signal signal.signal(signal.SIGINT, __signal_handler) # Glances can be ran in standalone, client or server mode if core.is_standalone(): logger.info("Start standalone mode") # Import the Glances standalone module from glances.standalone import GlancesStandalone # Init the standalone mode standalone = GlancesStandalone(config=core.get_config(), args=core.get_args()) # Start the standalone (CLI) loop standalone.serve_forever() elif core.is_client(): if core.is_client_browser(): logger.info("Start client mode (browser)") # Import the Glances client browser module from glances.client_browser import GlancesClientBrowser # Init the client client = GlancesClientBrowser(config=core.get_config(), args=core.get_args()) else: logger.info("Start client mode") # Import the Glances client module from glances.client import GlancesClient # Init the client client = GlancesClient(config=core.get_config(), args=core.get_args()) # Test if client and server are in the same major version if not client.login(): logger.critical( "The server version is not compatible with the client") sys.exit(2) # Start the client loop client.serve_forever() # Shutdown the client client.end() elif core.is_server(): logger.info("Start server mode") # Import the Glances server module from glances.server import GlancesServer args = core.get_args() server = GlancesServer(cached_time=core.cached_time, config=core.get_config(), args=args) print('Glances server is running on {0}:{1}'.format( args.bind_address, args.port)) # Set the server login/password (if -P/--password tag) if args.password != "": server.add_user(args.username, args.password) # Start the server loop server.serve_forever() # Shutdown the server? server.server_close() elif core.is_webserver(): logger.info("Start web server mode") # Import the Glances web server module from glances.webserver import GlancesWebServer # Init the web server mode webserver = GlancesWebServer(config=core.get_config(), args=core.get_args()) # Start the web server loop webserver.serve_forever()
def main(): """Main entry point for Glances. Select the mode (standalone, client or server) Run it... """ # Log Glances and PSutil version logger.info('Start Glances {0}'.format(__version__)) logger.info('{0} {1} and PSutil {2} detected'.format( platform.python_implementation(), platform.python_version(), psutil_version)) # Share global var global core, standalone, client, server, webserver # Create the Glances main instance core = GlancesMain() # Catch the CTRL-C signal signal.signal(signal.SIGINT, __signal_handler) # Glances can be ran in standalone, client or server mode if core.is_standalone(): logger.info("Start standalone mode") # Import the Glances standalone module from glances.standalone import GlancesStandalone # Init the standalone mode standalone = GlancesStandalone(config=core.get_config(), args=core.get_args()) # Start the standalone (CLI) loop standalone.serve_forever() elif core.is_client(): if core.is_client_browser(): logger.info("Start client mode (browser)") # Import the Glances client browser module from glances.client_browser import GlancesClientBrowser # Init the client client = GlancesClientBrowser(config=core.get_config(), args=core.get_args()) else: logger.info("Start client mode") # Import the Glances client module from glances.client import GlancesClient # Init the client client = GlancesClient(config=core.get_config(), args=core.get_args()) # Test if client and server are in the same major version if not client.login(): logger.critical("The server version is not compatible with the client") sys.exit(2) # Start the client loop client.serve_forever() # Shutdown the client client.end() elif core.is_server(): logger.info("Start server mode") # Import the Glances server module from glances.server import GlancesServer args = core.get_args() server = GlancesServer(cached_time=core.cached_time, config=core.get_config(), args=args) print('Glances server is running on {0}:{1}'.format(args.bind_address, args.port)) # Set the server login/password (if -P/--password tag) if args.password != "": server.add_user(args.username, args.password) # Start the server loop server.serve_forever() # Shutdown the server? server.server_close() elif core.is_webserver(): logger.info("Start web server mode") # Import the Glances web server module from glances.webserver import GlancesWebServer # Init the web server mode webserver = GlancesWebServer(config=core.get_config(), args=core.get_args()) # Start the web server loop webserver.serve_forever()