Commit bf27d561 authored by kaiyou's avatar kaiyou

Add the ability to specify multiple instances for a single check

parent 0dbc570e
...@@ -17,11 +17,19 @@ class Scheduler(object): ...@@ -17,11 +17,19 @@ class Scheduler(object):
""" Called by celery upon configuration so we can add beat tasks """ Called by celery upon configuration so we can add beat tasks
""" """
for name, check in app.config["checks"].items(): for name, check in app.config["checks"].items():
instances = check.get("instances", {name: {}})
context = check.get("context", {})
args = check.get("args", {})
for name, instance in instances.items():
instance_context = context.copy()
instance_context.update(instance.get("context", {}))
instance_args = args.copy()
instance_args.update(instance.get("args", {}))
app.add_periodic_task( app.add_periodic_task(
check["schedule"], instance.get("schedule", check["schedule"]),
check_run.s( check_run.s(
name, check["function"], name, instance.get("function", check["function"]),
check.get("context", {}), check.get("args", {}) instance_context, instance_args
) )
) )
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment