How to use the oncall.messengers.init_messengers function in oncall

To help you get started, we’ve selected a few oncall examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github linkedin / oncall / src / oncall / bin / notifier.py View on Github external
def main():
    with open(sys.argv[1], 'r') as config_file:
        config = yaml.safe_load(config_file)

    init_notifier(config)
    metrics_on = False
    if 'metrics' in config:
        metrics.init(config, 'oncall-notifier', {'message_blackhole_cnt': 0, 'message_sent_cnt': 0, 'message_fail_cnt': 0})
        metrics_worker = spawn(metrics_sender)
        metrics_on = True
    else:
        logger.warning('Not running with metrics')

    init_messengers(config.get('messengers', []))

    worker_tasks = [spawn(worker) for x in xrange(100)]
    reminder_on = False
    if config['reminder']['activated']:
        reminder_worker = spawn(reminder.reminder, config['reminder'])
        reminder_on = True
    validator_on = False
    if config['user_validator']['activated']:
        validator_worker = spawn(user_validator.user_validator, config['user_validator'])
        validator_on = True

    interval = 60

    logger.info('[*] notifier bootstrapped')
    while True:
        runtime = int(time.time())