def __init__(self, base_dir, channels, qualities, static_nodes=[], start=None, delete_old=False, run_once=False, node_file=None, node_database=None, localhost=None, download_concurrency=5, recent_cutoff=120): """Constructor for BackfillerManager. Creates a manager for a given channel with specified qualities.""" self.base_dir = base_dir self.channels = channels self.qualities = qualities self.static_nodes = static_nodes self.start = start self.delete_old = delete_old self.run_once = run_once self.node_file = node_file self.db_manager = None if node_database is None else database.DBManager( dsn=node_database) self.connection = None self.localhost = localhost self.download_concurrency = download_concurrency self.recent_cutoff = recent_cutoff self.stopping = gevent.event.Event() self.logger = logging.getLogger("BackfillerManager") self.workers = {} # {node url: worker}
def main(connection_string, default_channel, bustime_start, host='0.0.0.0', port=8004, backdoor_port=0, no_authentication=False, title_header=None, description_footer=None, upload_locations=''): """Thrimshim service.""" server = WSGIServer((host, port), cors(app)) app.no_authentication = no_authentication app.default_channel = default_channel app.bustime_start = bustime_start app.title_header = "" if title_header is None else "{} - ".format( title_header) app.description_footer = "" if description_footer is None else "\n\n{}".format( description_footer) app.upload_locations = upload_locations.split( ',') if upload_locations else [] stopping = gevent.event.Event() def stop(): logging.info("Shutting down") stopping.set() # handle when the server is running if hasattr(server, 'socket'): server.stop() # and when not else: sys.exit() gevent.signal(signal.SIGTERM, stop) app.db_manager = database.DBManager(dsn=connection_string) common.PromLogCountsHandler.install() common.install_stacksampler() if backdoor_port: gevent.backdoor.BackdoorServer(('127.0.0.1', backdoor_port), locals=locals()).start() logging.info('Starting up') if app.no_authentication: logging.warning('Not authenticating POST requests') server.serve_forever() logging.info("Gracefully shut down")
def __init__(self, channel, qualities, base_dir, first_hour, last_hour, make_page, connection_string): """Constructor for CoverageChecker. Creates a checker for a given channel with specified qualities.""" self.base_dir = base_dir self.channel = channel self.qualities = qualities self.first_hour = first_hour self.last_hour = last_hour self.make_page = make_page self.db_manager = None if connection_string is None else database.DBManager(dsn=connection_string) self.stopping = gevent.event.Event() self.logger = logging.getLogger('CoverageChecker({})'.format(channel))
def main( connection_string, default_channel, bustime_start, host='0.0.0.0', port=8004, backdoor_port=0, no_authentication=False, title_header=None, description_footer=None, upload_locations='', ): server = WSGIServer((host, port), cors(app)) app.no_authentication = no_authentication app.default_channel = default_channel app.bustime_start = bustime_start app.title_header = "" if title_header is None else "{} - ".format( title_header) app.description_footer = "" if description_footer is None else "\n\n{}".format( description_footer) app.upload_locations = upload_locations.split( ',') if upload_locations else [] app.db_manager = database.DBManager(dsn=connection_string) common.PromLogCountsHandler.install() common.install_stacksampler() if backdoor_port: gevent.backdoor.BackdoorServer(('127.0.0.1', backdoor_port), locals=locals()).start() if app.no_authentication: logging.warning('Not authenticating POST requests') common.serve_with_graceful_shutdown(server)