How to use the oncall.utils 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 / run_server.py View on Github external
def main():
    if len(sys.argv) <= 1:
        sys.exit('USAGE: %s CONFIG_FILE [--skip-build-assets]' % sys.argv[0])
    elif len(sys.argv) >= 3:
        skip_build_assets = (sys.argv[2] == '--skip-build-assets')
    else:
        skip_build_assets = False

    config = oncall.utils.read_config(sys.argv[1])
    server = config['server']

    options = {
        'preload_app': False,
        'reload': True,
        'bind': '%s:%s' % (server['host'], server['port']),
        'worker_class': 'gevent',
        'accesslog': '-',
        'workers': multiprocessing.cpu_count()
    }

    gunicorn_server = StandaloneApplication(options, skip_build_assets)
    gunicorn_server.run()
github linkedin / oncall / src / oncall / bin / scheduler.py View on Github external
def main():
    config = utils.read_config(sys.argv[1])
    db.init(config['db'])

    cycle_time = config.get('scheduler_cycle_time', 3600)
    schedulers = {}

    while 1:
        connection = db.connect()
        db_cursor = connection.cursor(db.DictCursor)

        start = time.time()
        # Load all schedulers
        db_cursor.execute('SELECT name FROM scheduler')
        schedulers = {}
        for row in db_cursor:
            try:
                scheduler_name = row['name']
github linkedin / oncall / src / oncall / bin / run_server.py View on Github external
def load(self):
        import oncall
        reload(oncall.utils)

        import oncall.app
        app = oncall.app.get_wsgi_app()

        if not self.skip_build_assets:
            for r in gc.get_referrers(self):
                if isinstance(r, dict) and '_num_workers' in r:
                    gunicorn_arbiter = r

            # only build assets on one worker to avoid race conditions
            if gunicorn_arbiter['worker_age'] % self.options['workers'] == 0:
                import oncall.ui
                oncall.ui.build_assets()

        return app