mirror of
https://github.com/inventree/InvenTree.git
synced 2025-10-23 17:37:38 +00:00
Tweak for plugin loading (#10631)
Prevent plugin install on server launch under certain conditions
This commit is contained in:
@@ -27,10 +27,10 @@ from django.utils.translation import gettext_lazy as _
|
|||||||
import structlog
|
import structlog
|
||||||
|
|
||||||
import InvenTree.cache
|
import InvenTree.cache
|
||||||
|
import InvenTree.ready
|
||||||
from common.settings import get_global_setting, set_global_setting
|
from common.settings import get_global_setting, set_global_setting
|
||||||
from InvenTree.config import get_plugin_dir
|
from InvenTree.config import get_plugin_dir
|
||||||
from InvenTree.exceptions import log_error
|
from InvenTree.exceptions import log_error
|
||||||
from InvenTree.ready import canAppAccessDatabase
|
|
||||||
|
|
||||||
from .helpers import (
|
from .helpers import (
|
||||||
IntegrationPluginError,
|
IntegrationPluginError,
|
||||||
@@ -152,6 +152,16 @@ class PluginsRegistry:
|
|||||||
|
|
||||||
# Install plugins from file (if required)
|
# Install plugins from file (if required)
|
||||||
if InvenTreeSetting.get_setting('PLUGIN_ON_STARTUP', create=False, cache=False):
|
if InvenTreeSetting.get_setting('PLUGIN_ON_STARTUP', create=False, cache=False):
|
||||||
|
if InvenTree.ready.isInTestMode() and not settings.PLUGIN_TESTING:
|
||||||
|
# Ignore plugin reload in test mode
|
||||||
|
pass
|
||||||
|
elif InvenTree.ready.isRunningBackup():
|
||||||
|
# Ignore plugin reload during backup
|
||||||
|
pass
|
||||||
|
elif InvenTree.ready.isGeneratingSchema():
|
||||||
|
# Ignore plugin reload during schema generation
|
||||||
|
pass
|
||||||
|
elif InvenTree.ready.isInWorkerThread() or InvenTree.ready.isInMainThread():
|
||||||
# make sure all plugins are installed
|
# make sure all plugins are installed
|
||||||
registry.install_plugin_file()
|
registry.install_plugin_file()
|
||||||
|
|
||||||
@@ -375,7 +385,7 @@ class PluginsRegistry:
|
|||||||
logger.debug('Finished loading plugins')
|
logger.debug('Finished loading plugins')
|
||||||
|
|
||||||
# Trigger plugins_loaded event
|
# Trigger plugins_loaded event
|
||||||
if canAppAccessDatabase():
|
if InvenTree.ready.canAppAccessDatabase():
|
||||||
from plugin.events import PluginEvents, trigger_event
|
from plugin.events import PluginEvents, trigger_event
|
||||||
|
|
||||||
trigger_event(PluginEvents.PLUGINS_LOADED)
|
trigger_event(PluginEvents.PLUGINS_LOADED)
|
||||||
@@ -1033,7 +1043,7 @@ class PluginsRegistry:
|
|||||||
# Skip if running during unit testing
|
# Skip if running during unit testing
|
||||||
return False
|
return False
|
||||||
|
|
||||||
if not canAppAccessDatabase(
|
if not InvenTree.ready.canAppAccessDatabase(
|
||||||
allow_shell=True, allow_test=settings.PLUGIN_TESTING_RELOAD
|
allow_shell=True, allow_test=settings.PLUGIN_TESTING_RELOAD
|
||||||
):
|
):
|
||||||
# Skip check if database cannot be accessed
|
# Skip check if database cannot be accessed
|
||||||
|
Reference in New Issue
Block a user