Merge pull request #17146 from open-craft/clemente/move-heartbeat-settings-to-env
Allow customizing heartbeat checks
This commit is contained in:
@@ -269,6 +269,11 @@ STUDIO_SHORT_NAME = ENV_TOKENS.get('STUDIO_SHORT_NAME', STUDIO_SHORT_NAME)
|
||||
if "TRACKING_IGNORE_URL_PATTERNS" in ENV_TOKENS:
|
||||
TRACKING_IGNORE_URL_PATTERNS = ENV_TOKENS.get("TRACKING_IGNORE_URL_PATTERNS")
|
||||
|
||||
# Heartbeat
|
||||
HEARTBEAT_CHECKS = ENV_TOKENS.get('HEARTBEAT_CHECKS', HEARTBEAT_CHECKS)
|
||||
HEARTBEAT_EXTENDED_CHECKS = ENV_TOKENS.get('HEARTBEAT_EXTENDED_CHECKS', HEARTBEAT_EXTENDED_CHECKS)
|
||||
HEARTBEAT_CELERY_TIMEOUT = ENV_TOKENS.get('HEARTBEAT_CELERY_TIMEOUT', HEARTBEAT_CELERY_TIMEOUT)
|
||||
|
||||
# Django CAS external authentication settings
|
||||
CAS_EXTRA_LOGIN_PARAMS = ENV_TOKENS.get("CAS_EXTRA_LOGIN_PARAMS", None)
|
||||
if FEATURES.get('AUTH_USE_CAS'):
|
||||
|
||||
@@ -76,6 +76,11 @@ from lms.envs.common import (
|
||||
|
||||
STATICI18N_OUTPUT_DIR,
|
||||
|
||||
# Heartbeat
|
||||
HEARTBEAT_CHECKS,
|
||||
HEARTBEAT_EXTENDED_CHECKS,
|
||||
HEARTBEAT_CELERY_TIMEOUT,
|
||||
|
||||
# Theme to use when no site or site theme is defined,
|
||||
DEFAULT_SITE_THEME,
|
||||
|
||||
|
||||
@@ -638,6 +638,11 @@ TRACKING_SEGMENTIO_DISALLOWED_SUBSTRING_NAMES = ENV_TOKENS.get(
|
||||
)
|
||||
TRACKING_SEGMENTIO_SOURCE_MAP = ENV_TOKENS.get("TRACKING_SEGMENTIO_SOURCE_MAP", TRACKING_SEGMENTIO_SOURCE_MAP)
|
||||
|
||||
# Heartbeat
|
||||
HEARTBEAT_CHECKS = ENV_TOKENS.get('HEARTBEAT_CHECKS', HEARTBEAT_CHECKS)
|
||||
HEARTBEAT_EXTENDED_CHECKS = ENV_TOKENS.get('HEARTBEAT_EXTENDED_CHECKS', HEARTBEAT_EXTENDED_CHECKS)
|
||||
HEARTBEAT_CELERY_TIMEOUT = ENV_TOKENS.get('HEARTBEAT_CELERY_TIMEOUT', HEARTBEAT_CELERY_TIMEOUT)
|
||||
|
||||
# Student identity verification settings
|
||||
VERIFY_STUDENT = AUTH_TOKENS.get("VERIFY_STUDENT", VERIFY_STUDENT)
|
||||
DISABLE_ACCOUNT_ACTIVATION_REQUIREMENT_SWITCH = ENV_TOKENS.get(
|
||||
|
||||
@@ -732,6 +732,21 @@ USERNAME_REGEX_PARTIAL = r'[\w .@_+-]+'
|
||||
USERNAME_PATTERN = r'(?P<username>{regex})'.format(regex=USERNAME_REGEX_PARTIAL)
|
||||
|
||||
|
||||
############################## HEARTBEAT ######################################
|
||||
|
||||
# Checks run in normal mode by the heartbeat djangoapp
|
||||
HEARTBEAT_CHECKS = [
|
||||
'openedx.core.djangoapps.heartbeat.default_checks.check_modulestore',
|
||||
'openedx.core.djangoapps.heartbeat.default_checks.check_database',
|
||||
]
|
||||
|
||||
# Other checks to run by default in "extended"/heavy mode
|
||||
HEARTBEAT_EXTENDED_CHECKS = (
|
||||
'openedx.core.djangoapps.heartbeat.default_checks.check_celery',
|
||||
)
|
||||
|
||||
HEARTBEAT_CELERY_TIMEOUT = 5
|
||||
|
||||
############################## EVENT TRACKING #################################
|
||||
LMS_SEGMENT_KEY = None
|
||||
|
||||
|
||||
@@ -13,7 +13,6 @@ from django.db.utils import DatabaseError
|
||||
from xmodule.modulestore.django import modulestore
|
||||
from xmodule.exceptions import HeartbeatFailure
|
||||
|
||||
from .defaults import HEARTBEAT_CELERY_TIMEOUT
|
||||
from .tasks import sample_task
|
||||
|
||||
|
||||
@@ -107,7 +106,7 @@ def check_celery():
|
||||
"""
|
||||
now = time()
|
||||
datetimenow = datetime.now()
|
||||
expires = datetimenow + timedelta(seconds=getattr(settings, 'HEARTBEAT_CELERY_TIMEOUT', HEARTBEAT_CELERY_TIMEOUT))
|
||||
expires = datetimenow + timedelta(seconds=settings.HEARTBEAT_CELERY_TIMEOUT)
|
||||
|
||||
try:
|
||||
task = sample_task.apply_async(expires=expires)
|
||||
|
||||
@@ -1,17 +0,0 @@
|
||||
"""
|
||||
Configuration defaults for the heartbeat djangoapp
|
||||
|
||||
Configures what checks to run by default in normal and "extended"/heavy mode,
|
||||
as well as providing settings for the default checks themselves
|
||||
"""
|
||||
|
||||
HEARTBEAT_DEFAULT_CHECKS = [
|
||||
'.default_checks.check_modulestore',
|
||||
'.default_checks.check_database',
|
||||
]
|
||||
|
||||
HEARTBEAT_EXTENDED_DEFAULT_CHECKS = (
|
||||
'.default_checks.check_celery',
|
||||
)
|
||||
|
||||
HEARTBEAT_CELERY_TIMEOUT = 5
|
||||
@@ -3,8 +3,6 @@ from importlib import import_module
|
||||
from django.conf import settings
|
||||
from django.core.exceptions import ImproperlyConfigured
|
||||
|
||||
from .defaults import HEARTBEAT_DEFAULT_CHECKS, HEARTBEAT_EXTENDED_DEFAULT_CHECKS
|
||||
|
||||
|
||||
def runchecks(include_extended=False):
|
||||
"""
|
||||
@@ -13,11 +11,9 @@ def runchecks(include_extended=False):
|
||||
"""
|
||||
response_dict = {}
|
||||
|
||||
#Taken straight from Django
|
||||
#If there is a better way, I don't know it
|
||||
list_of_checks = getattr(settings, 'HEARTBEAT_CHECKS', HEARTBEAT_DEFAULT_CHECKS)
|
||||
list_of_checks = list(settings.HEARTBEAT_CHECKS)
|
||||
if include_extended:
|
||||
list_of_checks += getattr(settings, 'HEARTBEAT_EXTENDED_CHECKS', HEARTBEAT_EXTENDED_DEFAULT_CHECKS)
|
||||
list_of_checks += settings.HEARTBEAT_EXTENDED_CHECKS
|
||||
|
||||
for path in list_of_checks:
|
||||
module, _, attr = path.rpartition('.')
|
||||
|
||||
Reference in New Issue
Block a user