How to use the oncall.notifier.reminder.reminder 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
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())
        logger.info('--> notifier loop started.')
        poll()

        # check status for all background greenlets and respawn if necessary
        bad_workers = []
github linkedin / oncall / src / oncall / bin / notifier.py View on Github external
# check status for all background greenlets and respawn if necessary
        bad_workers = []
        for i, task in enumerate(worker_tasks):
            if not bool(task):
                logger.error("worker task failed, %s", task.exception)
                bad_workers.append(i)
        for i in bad_workers:
            worker_tasks[i] = spawn(worker)
        # Check greenlet health for metrics, reminder, and validator tasks
        if metrics_on and not bool(metrics_worker):
            logger.error("metrics worker failed, %s", metrics_worker.exception)
            metrics_worker = spawn(metrics_sender)
        if reminder_on and not bool(reminder_worker):
            logger.error("reminder worker failed, %s", reminder_worker.exception)
            reminder_worker = spawn(reminder.reminder, config['reminder'])
        if validator_on and not bool(validator_worker):
            logger.error("user validator failed, %s", validator_worker.exception)
            validator_worker = spawn(user_validator.user_validator, config['user_validator'])

        now = time.time()
        elapsed_time = now - runtime
        nap_time = max(0, interval - elapsed_time)
        logger.info('--> notifier loop finished in %s seconds - sleeping %s seconds',
                    elapsed_time, nap_time)
        sleep(nap_time)