From 28fe8c8c3e6f8b155187d05f9ebdbc31b93bf372 Mon Sep 17 00:00:00 2001 From: Sunil Mohan Adapa Date: Wed, 24 Jun 2020 14:35:45 -0700 Subject: [PATCH] web_framework: Split initialization into two parts A simple Django configuration does not need to create the database whereas DB migration requires creating the database. In some operations such as listing dependencies, we can skip running the second part and so writing to database will no longer be necessary during such operations. Signed-off-by: Sunil Mohan Adapa Reviewed-by: James Valleroy --- plinth/__main__.py | 1 + plinth/web_framework.py | 3 +++ 2 files changed, 4 insertions(+) diff --git a/plinth/__main__.py b/plinth/__main__.py index 70f9e7580..84978bf0f 100644 --- a/plinth/__main__.py +++ b/plinth/__main__.py @@ -132,6 +132,7 @@ def main(): log.init() web_framework.init() + web_framework.post_init() logger.info('FreedomBox Service (Plinth) version - %s', __version__) for config_file in cfg.config_files: diff --git a/plinth/web_framework.py b/plinth/web_framework.py index b5f68e80d..6aa25cd28 100644 --- a/plinth/web_framework.py +++ b/plinth/web_framework.py @@ -53,6 +53,9 @@ def init(): logger.debug('Configured Django with applications - %s', settings.INSTALLED_APPS) + +def post_init(): + """Perform operations after completing init of other modules.""" logger.debug('Creating or adding new tables to data file') django.core.management.call_command('migrate', '--fake-initial', interactive=False, verbosity=0)