Commit bf27d561 authored by kaiyou's avatar kaiyou

Add the ability to specify multiple instances for a single check

parent 0dbc570e
...@@ -17,13 +17,21 @@ class Scheduler(object): ...@@ -17,13 +17,21 @@ 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():
app.add_periodic_task( instances = check.get("instances", {name: {}})
check["schedule"], context = check.get("context", {})
check_run.s( args = check.get("args", {})
name, check["function"], for name, instance in instances.items():
check.get("context", {}), check.get("args", {}) instance_context = context.copy()
instance_context.update(instance.get("context", {}))
instance_args = args.copy()
instance_args.update(instance.get("args", {}))
app.add_periodic_task(
instance.get("schedule", check["schedule"]),
check_run.s(
name, instance.get("function", check["function"]),
instance_context, instance_args
)
) )
)
def update(self, name, context, status, result): def update(self, name, context, status, result):
""" Handle a status update for a given check """ Handle a status update for a given check
......
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