mirror of
				https://github.com/inventree/InvenTree.git
				synced 2025-10-31 21:25:42 +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 InvenTree.cache | ||||
| import InvenTree.ready | ||||
| from common.settings import get_global_setting, set_global_setting | ||||
| from InvenTree.config import get_plugin_dir | ||||
| from InvenTree.exceptions import log_error | ||||
| from InvenTree.ready import canAppAccessDatabase | ||||
|  | ||||
| from .helpers import ( | ||||
|     IntegrationPluginError, | ||||
| @@ -152,8 +152,18 @@ class PluginsRegistry: | ||||
|  | ||||
|         # Install plugins from file (if required) | ||||
|         if InvenTreeSetting.get_setting('PLUGIN_ON_STARTUP', create=False, cache=False): | ||||
|             # make sure all plugins are installed | ||||
|             registry.install_plugin_file() | ||||
|             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 | ||||
|                 registry.install_plugin_file() | ||||
|  | ||||
|         # Perform initial plugin discovery | ||||
|         self.reload_plugins(full_reload=True, force_reload=True, collect=True) | ||||
| @@ -375,7 +385,7 @@ class PluginsRegistry: | ||||
|         logger.debug('Finished loading plugins') | ||||
|  | ||||
|         # Trigger plugins_loaded event | ||||
|         if canAppAccessDatabase(): | ||||
|         if InvenTree.ready.canAppAccessDatabase(): | ||||
|             from plugin.events import PluginEvents, trigger_event | ||||
|  | ||||
|             trigger_event(PluginEvents.PLUGINS_LOADED) | ||||
| @@ -1033,7 +1043,7 @@ class PluginsRegistry: | ||||
|             # Skip if running during unit testing | ||||
|             return False | ||||
|  | ||||
|         if not canAppAccessDatabase( | ||||
|         if not InvenTree.ready.canAppAccessDatabase( | ||||
|             allow_shell=True, allow_test=settings.PLUGIN_TESTING_RELOAD | ||||
|         ): | ||||
|             # Skip check if database cannot be accessed | ||||
|   | ||||
		Reference in New Issue
	
	Block a user