diff --git a/mistral/config.py b/mistral/config.py index 444423e4d..eff0396dd 100644 --- a/mistral/config.py +++ b/mistral/config.py @@ -251,6 +251,20 @@ cron_trigger_opts = [ ' performance.' ) ), + cfg.IntOpt( + 'execution_interval', + default=1, + min=1, + help=( + 'This setting defines how frequently Mistral checks for cron ', + 'triggers that need execution. By default this is every second ', + 'which can lead to high system load. Increasing the number will ', + 'reduce the load but also limit the minimum freqency. For ', + 'example, a cron trigger can be configured to run every second ', + 'but if the execution_interval is set to 60, it will only run ', + 'once per minute.' + ) + ) ] event_engine_opts = [ diff --git a/mistral/services/periodic.py b/mistral/services/periodic.py index c15d160f5..84691bf57 100644 --- a/mistral/services/periodic.py +++ b/mistral/services/periodic.py @@ -35,7 +35,8 @@ _periodic_tasks = {} class MistralPeriodicTasks(periodic_task.PeriodicTasks): - @periodic_task.periodic_task(spacing=1, run_immediately=True) + @periodic_task.periodic_task(spacing=CONF.cron_trigger.execution_interval, + run_immediately=True) def process_cron_triggers_v2(self, ctx): LOG.debug("Processing cron triggers...")