Added env to docker web credentials.py to set the background task interval

This commit is contained in:
Dana Van Aken 2020-04-17 18:17:52 -04:00
parent c9370b76a3
commit d47b09b0c0
1 changed files with 11 additions and 0 deletions

View File

@ -1,6 +1,7 @@
import json import json
import random import random
import string import string
from datetime import timedelta
from os import environ as env from os import environ as env
debug = env.get('DEBUG', 'true').lower() == 'true' debug = env.get('DEBUG', 'true').lower() == 'true'
@ -9,6 +10,7 @@ backend = env.get('BACKEND', 'postgresql')
db_name = env.get('DB_NAME', 'ottertune') db_name = env.get('DB_NAME', 'ottertune')
db_host = env.get('DB_HOST', 'localhost') db_host = env.get('DB_HOST', 'localhost')
db_pwd = env.get('DB_PASSWORD', '') db_pwd = env.get('DB_PASSWORD', '')
bg_run_every = env.get('BG_TASKS_RUN_EVERY', None) # minutes
if backend == 'mysql': if backend == 'mysql':
default_user = 'root' default_user = 'root'
@ -43,3 +45,12 @@ ADMINS = ()
MANAGERS = ADMINS MANAGERS = ADMINS
ALLOWED_HOSTS = ['*'] ALLOWED_HOSTS = ['*']
BROKER_URL = 'amqp://guest:guest@{}:5672//'.format(rabbitmq_host) BROKER_URL = 'amqp://guest:guest@{}:5672//'.format(rabbitmq_host)
if bg_run_every is not None:
# Defines the periodic task schedule for celerybeat
CELERYBEAT_SCHEDULE = {
'run-every-{}m'.format(bg_run_every): {
'task': 'run_background_tasks',
'schedule': timedelta(minutes=int(bg_run_every)),
}
}