Skip to content

Commit

Permalink
Merge a325cae into f744ed0
Browse files Browse the repository at this point in the history
  • Loading branch information
ddurieux committed Feb 1, 2017
2 parents f744ed0 + a325cae commit 7adeace
Showing 1 changed file with 39 additions and 30 deletions.
69 changes: 39 additions & 30 deletions alignak_backend/app.py
Expand Up @@ -1460,36 +1460,45 @@ def get_settings(prev_settings):

# scheduler config
jobs = []
if settings['SCHEDULER_TIMESERIES_ACTIVE']:
jobs.append(
{
'id': 'cron_cache',
'func': 'alignak_backend.scheduler:cron_cache',
'args': (),
'trigger': 'interval',
'seconds': 10
}
)
if settings['SCHEDULER_GRAFANA_ACTIVE']:
jobs.append(
{
'id': 'cron_grafana',
'func': 'alignak_backend.scheduler:cron_grafana',
'args': (),
'trigger': 'interval',
'seconds': 120
}
)
if settings['SCHEDULER_LIVESYNTHESIS_HISTORY']:
jobs.append(
{
'id': 'cron_livesynthesis_history',
'func': 'alignak_backend.scheduler:cron_livesynthesis_history',
'args': (),
'trigger': 'interval',
'seconds': 60
}
)
# run only sheduler on uwsgi worker 1, because option lazy-apps in uwsgi will run the
# scheduler on each worker and we don't want that ;)
try:
import uwsgi
worker_id = uwsgi.worker_id()
except ImportError:
worker_id = 1

if worker_id == 1:
if settings['SCHEDULER_TIMESERIES_ACTIVE']:
jobs.append(
{
'id': 'cron_cache',
'func': 'alignak_backend.scheduler:cron_cache',
'args': (),
'trigger': 'interval',
'seconds': 10
}
)
if settings['SCHEDULER_GRAFANA_ACTIVE']:
jobs.append(
{
'id': 'cron_grafana',
'func': 'alignak_backend.scheduler:cron_grafana',
'args': (),
'trigger': 'interval',
'seconds': 120
}
)
if settings['SCHEDULER_LIVESYNTHESIS_HISTORY']:
jobs.append(
{
'id': 'cron_livesynthesis_history',
'func': 'alignak_backend.scheduler:cron_livesynthesis_history',
'args': (),
'trigger': 'interval',
'seconds': 60
}
)
if len(jobs) > 0:
settings['JOBS'] = jobs

Expand Down

0 comments on commit 7adeace

Please sign in to comment.