예제 #1
0
    def start(self):
        signal.signal(signal.SIGTERM, self.die)

        log.info('Starting Inferno...')
        auto_rules = get_rules(self.settings['rules_directory'])

        pid_dir = pid.pid_dir(self.settings)

        # keep cycling through the automatic rules
        while not self.stopped:
            # cycle through all the automatic rules
            for rule in auto_rules:
                if self.stopped:
                    break
                # skip this rule
                # check if pid file exists
                if not rule.run or self.paused or not pid.should_run(
                        pid_dir, rule):
                    continue

                pid.create_pid(pid_dir, rule, 'N/A')
                pid.create_last_run(pid_dir, rule)
                self.run_rule(rule)
            time.sleep(1)
        self.die()
예제 #2
0
 def test_get_automatic_rules(self):
     rules = get_rules(self.rules_dir)
     actual = sorted([rule.name for rule in rules])
     expected = [
         'automatic_rule_1', 'automatic_rule_2', 'automatic_rule_3',
         'automatic_rule_4'
     ]
     eq_(actual, expected)
예제 #3
0
 def test_get_automatic_rules(self):
     rules = get_rules(self.rules_dir)
     actual = sorted([rule.name for rule in rules])
     expected = [
         'automatic_rule_1',
         'automatic_rule_2',
         'automatic_rule_3',
         'automatic_rule_4']
     eq_(actual, expected)
예제 #4
0
파일: daemon.py 프로젝트: mkhaitman/inferno
    def start(self):
        signal.signal(signal.SIGTERM, self.die)

        log.info('Starting Inferno...')
        auto_rules = get_rules(self.settings['rules_directory'])

        pid_dir = pid.pid_dir(self.settings)

        # keep cycling through the automatic rules
        while not self.stopped:
            # cycle through all the automatic rules
            for rule in auto_rules:
                if self.stopped:
                    break
                # skip this rule
                # check if pid file exists
                if not rule.run or self.paused or not pid.should_run(pid_dir, rule):
                    continue

                pid.create_pid(pid_dir, rule, 'N/A')
                self.run_rule(rule)
            time.sleep(1)
        self.die()