mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-06-17 11:10:23 +00:00
module_loader: Load/process all essential modules before others
Since modules need not have dependency on any essential module even though they are dependent on them, it must be assumed that any module may depend on any essential module. So, load or process (like running setup) essential modules before non-essential modules. Closes: #1967. Tests: - When service is started, console messages show that in the module load order, all the essential modules are prioritized. - Without these changes, this is not the case. - When version of essential app and non-essential app are incremented, essential app is setup before the non-essential app. Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org> Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
This commit is contained in:
parent
694866e4b2
commit
00b551972b
@ -28,6 +28,11 @@ def include_urls():
|
||||
_include_module_urls(module_import_path, module_name)
|
||||
|
||||
|
||||
def _is_module_essential(module):
|
||||
"""Return if a module is an essential module."""
|
||||
return getattr(module, 'is_essential', False)
|
||||
|
||||
|
||||
def load_modules():
|
||||
"""
|
||||
Read names of enabled modules in modules/enabled directory and
|
||||
@ -47,7 +52,10 @@ def load_modules():
|
||||
|
||||
ordered_modules = []
|
||||
remaining_modules = dict(modules) # Make a copy
|
||||
for module_name in modules:
|
||||
# Place all essential modules ahead of others in module load order
|
||||
sorted_modules = sorted(
|
||||
modules, key=lambda module: not _is_module_essential(modules[module]))
|
||||
for module_name in sorted_modules:
|
||||
if module_name not in remaining_modules:
|
||||
continue
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user