Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions cms/startup.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
"""
Module with code executed during Studio startup
"""
import logging
from django.conf import settings

# Force settings to run so that the python path is modified
settings.INSTALLED_APPS # pylint: disable=W0104

from django_startup import autostartup

log = logging.getLogger(__name__)

# TODO: Remove this code once Studio/CMS runs via wsgi in all environments
INITIALIZED = False
Expand Down
11 changes: 9 additions & 2 deletions common/lib/django_startup.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
"""
Automatic execution of startup modules in Django apps.
"""

from importlib import import_module
from django.conf import settings

Expand All @@ -6,9 +10,12 @@ def autostartup():
Execute app.startup:run() for all installed django apps
"""
for app in settings.INSTALLED_APPS:
# See if there's a startup module in each app.
try:
mod = import_module(app + '.startup')
if hasattr(mod, 'run'):
mod.run()
except ImportError:
continue

# If the module has a run method, run it.
if hasattr(mod, 'run'):
mod.run()
6 changes: 2 additions & 4 deletions lms/startup.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
"""
Module for code that should run during LMS startup
"""
import logging

from django.conf import settings

Expand All @@ -11,16 +10,15 @@
from django_startup import autostartup
from xmodule.modulestore.django import modulestore

log = logging.getLogger(__name__)

def run():
"""
Executed during django startup
"""
autostartup()

# Trigger a forced initialization of our modulestores since this can take a while to complete
# and we want this done before HTTP requests are accepted.
# Trigger a forced initialization of our modulestores since this can take a
# while to complete and we want this done before HTTP requests are accepted.
if settings.INIT_MODULESTORE_ON_STARTUP:
for store_name in settings.MODULESTORE:
modulestore(store_name)