module_loader, app: Move app init to app module

- Don't try to get the depends from module level and sort modules based on that.

- Instead after all App instances are created, sort the apps based on
app.info.depends and app.info.is_essential.

- Print message that apps have been initialized instead of printing before they
are initialized. The correct order of apps is only known after they have been
initialized and sorted.

- Avoid circular import on module_loader and setup.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
This commit is contained in:
Sunil Mohan Adapa authored and James Valleroy committed 2021-12-04 16:39:40 -05:00
1 parent 3421469825
commit 603b63bbac
7 files changed
+198 -109

No files matched your search

+5 -4
View File
@@ -7,8 +7,9 @@ Wrapper to list and handle system services
import argparse
import os
from plinth import action_utils, cfg, module_loader
from plinth.app import App
from plinth import action_utils
from plinth import app as app_module
from plinth import cfg, module_loader
from plinth.daemon import Daemon, RelatedDaemon
cfg.read()
@@ -90,8 +91,8 @@ def _get_managed_services():
"""Get a set of all services managed by FreedomBox."""
services = set()
module_loader.load_modules()
module_loader.apps_init()
for app in App.list():
app_module.apps_init()
for app in app_module.App.list():
components = app.get_components_of_type(Daemon)
for component in components:
services.add(component.unit)