Exemplo n.º 1
0
def run_checks(collector):
    """Just run the checks for our modules"""
    artifact = collector.configuration["dashmat"].artifact
    chosen = artifact
    if chosen in (None, "", NotSpecified):
        chosen = None

    dashmat = collector.configuration["dashmat"]
    modules = collector.configuration["__active_modules__"]
    config_root = collector.configuration["config_root"]
    module_options = collector.configuration["modules"]

    datastore = JsonDataStore(os.path.join(config_root, "data.json"))
    if dashmat.redis_host:
        datastore = RedisDataStore(redis.Redis(dashmat.redis_host))

    scheduler = Scheduler(datastore)

    for name, module in modules.items():
        if chosen is None or name == chosen:
            server = module.make_server(module_options[name].server_options)
            scheduler.register(module, server, name)

    scheduler.twitch(force=True)
Exemplo n.º 2
0
    def serve(self):
        http_server = HTTPServer(WSGIContainer(self.app))
        scheduler = Scheduler(self.datastore)
        if not self.without_checks:
            for name, (module, server) in self.servers.items():
                scheduler.register(module, server, name)

        try:
            if not self.without_checks:
                scheduler.start()
            http_server.listen(self.port, self.host)
            log.info("Starting server on http://%s:%s", self.host, self.port)

            try:
                IOLoop.instance().start()
            finally:
                self.thread_stopper["finished"] = True
        finally:
            scheduler.finish()