From 76cd6e019b0fb832e962aa266b249d1958a3b20f Mon Sep 17 00:00:00 2001 From: Oliver Walters Date: Mon, 18 Nov 2024 09:18:38 +0000 Subject: [PATCH] Revert check on startup --- docs/docs/settings/global.md | 1 + src/backend/InvenTree/common/models.py | 10 ++++++++++ src/backend/InvenTree/plugin/apps.py | 12 ++++++++++++ src/backend/InvenTree/plugin/installer.py | 2 +- 4 files changed, 24 insertions(+), 1 deletion(-) diff --git a/docs/docs/settings/global.md b/docs/docs/settings/global.md index 6540e9acde..241ac74f0d 100644 --- a/docs/docs/settings/global.md +++ b/docs/docs/settings/global.md @@ -210,6 +210,7 @@ Refer to the [return order settings](../order/return_order.md#return-order-setti | Name | Description | Default | Units | | ---- | ----------- | ------- | ----- | +{{ globalsetting("PLUGIN_ON_STARTUP") }} {{ globalsetting("PLUGIN_UPDATE_CHECK") }} {{ globalsetting("ENABLE_PLUGINS_URL") }} {{ globalsetting("ENABLE_PLUGINS_NAVIGATION") }} diff --git a/src/backend/InvenTree/common/models.py b/src/backend/InvenTree/common/models.py index e0de692135..fb57bfa67d 100644 --- a/src/backend/InvenTree/common/models.py +++ b/src/backend/InvenTree/common/models.py @@ -2110,6 +2110,16 @@ class InvenTreeSetting(BaseInvenTreeSetting): 'default': False, 'validator': bool, }, + 'PLUGIN_ON_STARTUP': { + 'name': _('Check plugins on startup'), + 'description': _( + 'Check that all plugins are installed on startup - enable in container environments' + ), + 'default': str(os.getenv('INVENTREE_DOCKER', 'False')).lower() + in ['1', 'true'], + 'validator': bool, + 'requires_restart': True, + }, 'PLUGIN_UPDATE_CHECK': { 'name': _('Check for plugin updates'), 'description': _('Enable periodic checks for updates to installed plugins'), diff --git a/src/backend/InvenTree/plugin/apps.py b/src/backend/InvenTree/plugin/apps.py index 8b481a304b..3c47bc70b0 100644 --- a/src/backend/InvenTree/plugin/apps.py +++ b/src/backend/InvenTree/plugin/apps.py @@ -34,6 +34,18 @@ class PluginAppConfig(AppConfig): logger.info('Loading InvenTree plugins') if not registry.is_loading: + # this is the first startup + try: + from common.models import InvenTreeSetting + + if InvenTreeSetting.get_setting( + 'PLUGIN_ON_STARTUP', create=False, cache=False + ): + # make sure all plugins are installed + registry.install_plugin_file() + except Exception: # pragma: no cover + pass + # Perform a full reload of the plugin registry registry.reload_plugins( full_reload=True, force_reload=True, collect=True diff --git a/src/backend/InvenTree/plugin/installer.py b/src/backend/InvenTree/plugin/installer.py index b5581bb421..9cc3917a85 100644 --- a/src/backend/InvenTree/plugin/installer.py +++ b/src/backend/InvenTree/plugin/installer.py @@ -113,7 +113,7 @@ def install_plugins_file(): logger.warning('Plugin file %s does not exist', str(pf)) return - cmd = ['install', '-U', '-r', str(pf)] + cmd = ['install', '--disable-pip-version-check', '-U', '-r', str(pf)] try: pip_command(*cmd)