コード例 #1
0
    def run(self):
        while True:
            try:
                with closing(Session()) as session:
                    self.logger.debug("Expiring edges....")
                    self.expire_edges(session)
                    self.logger.debug(
                        "Expiring nonauditor approvers in audited groups...")
                    self.expire_nonauditors(session)
                    self.logger.debug("Sending emails...")
                    process_async_emails(self.settings, session,
                                         datetime.utcnow())
                    self.logger.debug("Pruning old traces....")
                    prune_old_traces(session)
                    session.commit()

                stats.set_gauge("successful-background-update", 1)
            except OperationalError:
                Session.configure(
                    bind=get_db_engine(get_database_url(self.settings)))
                self.logger.critical("Failed to connect to database.")
                stats.set_gauge("successful-background-update", 0)
                stats.set_gauge("failed-background-update", 1)
                self.capture_exception()
            except:
                stats.set_gauge("successful-background-update", 0)
                stats.set_gauge("failed-background-update", 1)
                self.capture_exception()
                raise

            sleep(60)
コード例 #2
0
ファイル: settings.py プロジェクト: benjaminp/grouper
 def refresh_config_loop():
     while True:
         time.sleep(refresh_config_seconds)
         try:
             self._update_from_config(filename, section=section)
             stats.set_gauge("successful-config-update", 1)
         except (IOError, yaml.parser.ParserError):
             stats.set_gauge("successful-config-update", 0)
コード例 #3
0
 def refresh_config_loop():
     while True:
         time.sleep(refresh_config_seconds)
         try:
             self._update_from_config(filename, section=section)
             stats.set_gauge("successful-config-update", 1)
         except (IOError, yaml.parser.ParserError):
             stats.set_gauge("successful-config-update", 0)
コード例 #4
0
ファイル: database.py プロジェクト: Acidity/grouper
    def run(self):
        while True:
            self.logger.debug("Updating Graph from Database.")
            try:
                with closing(Session()) as session:
                    self.graph.update_from_db(session)

                stats.set_gauge("successful-db-update", 1)
            except OperationalError:
                Session.configure(bind=get_db_engine(get_database_url(self.settings)))
                self.logger.critical("Failed to connect to database.")
                stats.set_gauge("successful-db-update", 0)
                stats.set_gauge("failed-db-update", 1)
                self.capture_exception()
            except:
                stats.set_gauge("successful-db-update", 0)
                stats.set_gauge("failed-db-update", 1)
                self.capture_exception()
                raise

            sleep(self.refresh_interval)
コード例 #5
0
ファイル: database.py プロジェクト: graham/grouper
    def run(self):
        while True:
            self.logger.debug("Updating Graph from Database.")
            try:
                with closing(Session()) as session:
                    self.graph.update_from_db(session)

                stats.set_gauge("successful-db-update", 1)
            except OperationalError:
                Session.configure(
                    bind=get_db_engine(get_database_url(self.settings)))
                self.logger.critical("Failed to connect to database.")
                stats.set_gauge("successful-db-update", 0)
                stats.set_gauge("failed-db-update", 1)
                self.capture_exception()
            except:
                stats.set_gauge("successful-db-update", 0)
                stats.set_gauge("failed-db-update", 1)
                self.capture_exception()
                raise

            sleep(self.refresh_interval)
コード例 #6
0
ファイル: settings.py プロジェクト: tomeara-quora/merou
    def update_from_config(self, filename, section=None):
        self.logger.debug("Loading " + filename)
        with open(filename) as config:
            data = yaml.safe_load(config.read())

        settings = {}
        settings.update(data.get("common", {}))
        if section:
            settings.update(data.get(section, {}))

        for key, value in settings.iteritems():
            key = key.lower()

            # Limit the parts of the config file that can have an effect.
            if key not in self.settings:
                continue

            override = getattr(self, "override_%s" % key, None)
            if override is not None and callable(override):
                value = override(value)

            self[key] = value

        stats.set_gauge("successful-config-update", 1)
コード例 #7
0
ファイル: settings.py プロジェクト: Acidity/grouper
    def update_from_config(self, filename, section=None):
        self.logger.info("Loading " + filename)
        with open(filename) as config:
            data = yaml.safe_load(config.read())

        settings = {}
        settings.update(data.get("common", {}))
        if section:
            settings.update(data.get(section, {}))

        for key, value in settings.iteritems():
            key = key.lower()

            # Limit the parts of the config file that can have an effect.
            if key not in self.settings:
                continue

            override = getattr(self, "override_%s" % key, None)
            if override is not None and callable(override):
                value = override(value)

            self[key] = value

        stats.set_gauge("successful-config-update", 1)
コード例 #8
0
ファイル: background.py プロジェクト: benjaminp/grouper
 def run(self):
     while True:
         try:
             session = Session()
             logging.debug("Expiring edges....")
             self.expire_edges(session)
             logging.debug("Sending emails...")
             process_async_emails(self.settings, session, datetime.utcnow())
             logging.debug("Pruning old traces....")
             prune_old_traces(session)
             session.commit()
             session.close()
             stats.set_gauge("successful-background-run", 1)
         except OperationalError:
             Session.configure(bind=get_db_engine(get_database_url(self.settings)))
             logging.critical("Failed to connect to database.")
             stats.set_gauge("successful-background-run", 0)
             self.capture_exception()
         except:
             stats.set_gauge("successful-background-run", 0)
             self.capture_exception()
             raise
         sleep(60)
コード例 #9
0
ファイル: background.py プロジェクト: rra/grouper
    def run(self):
        while True:
            try:
                with closing(Session()) as session:
                    self.logger.debug("Expiring edges....")
                    self.expire_edges(session)
                    self.logger.debug("Expiring nonauditor approvers in audited groups...")
                    self.expire_nonauditors(session)
                    self.logger.debug("Sending emails...")
                    process_async_emails(self.settings, session, datetime.utcnow())
                    self.logger.debug("Pruning old traces....")
                    prune_old_traces(session)
                    session.commit()

                stats.set_gauge("successful-background-update", 1)
                stats.set_gauge("failed-background-update", 0)
            except OperationalError:
                Session.configure(bind=get_db_engine(get_database_url(self.settings)))
                self.logger.critical("Failed to connect to database.")
                stats.set_gauge("successful-background-update", 0)
                stats.set_gauge("failed-background-update", 1)
                self.capture_exception()
            except:
                stats.set_gauge("successful-background-update", 0)
                stats.set_gauge("failed-background-update", 1)
                self.capture_exception()
                raise

            sleep(60)