import sys import bottle from icalendar_timeseries_server.cal import start_scrape_calendar from icalendar_timeseries_server.config import load_config, load_default_config, get_config # Contains decorated bottle handler function for /api/v1/query # noinspection PyUnresolvedReferences from icalendar_timeseries_server.api import prometheus_api def main(): if len(sys.argv) == 1: load_default_config() elif len(sys.argv) == 2: load_config(sys.argv[1]) else: print(f'Can only read one config file, got "{" ".join(sys.argv[1:])}"') exit(1) config = get_config() # Schedule calendar scraping in the background for calname in config.calendars.keys(): start_scrape_calendar(calname, config.calendars[calname]) # Start the Bottle HTTP server bottle.run(host=config.addr, port=get_config().port) if __name__ == '__main__': main()