mirror of
https://github.com/inventree/InvenTree.git
synced 2025-07-10 23:14:13 +00:00
* Skip ready functions if not in main thread or plugins are not loaded yet
* Debug integration tests
* Update ready.py
* Update ready.py
* Fix isInMainThread and isPluginRegistryLoaded ready functions
* Preload gunicorn app to only invoke the appconfig ready functions once
* debug: test prints for statistics
* Remove debug print
* Test without
* Revert "Test without"
This reverts commit 1bc1872893
.
* Second test
* Add checks back to part, label, user model
* Add checks back to inventree, plugin apps
* log server output for debugging
* hopefully I can get the log this time+
* Next test
* Test with --noreload
* Next test
* trigger: ci, because session expired
* block the second ready execution instead of the first
* fix: load order
* Fix test and revert gh actions workflow change
* Added all_apps method to reload machanism
* Changed detect reload mechanism
* Also trigger ready on reload
* Add skipping second reload back for testing mode
* Added doc string back
* Update InvenTree/plugin/base/integration/AppMixin.py
52 lines
1.7 KiB
Python
52 lines
1.7 KiB
Python
"""Apps file for plugin app.
|
|
|
|
This initializes the plugin mechanisms and handles reloading throughout the lifecycle.
|
|
The main code for plugin special sauce is in the plugin registry in `InvenTree/plugin/registry.py`.
|
|
"""
|
|
|
|
import logging
|
|
|
|
from django.apps import AppConfig
|
|
|
|
from maintenance_mode.core import set_maintenance_mode
|
|
|
|
from InvenTree.ready import canAppAccessDatabase, isInMainThread
|
|
from plugin import registry
|
|
|
|
logger = logging.getLogger('inventree')
|
|
|
|
|
|
class PluginAppConfig(AppConfig):
|
|
"""AppConfig for plugins."""
|
|
|
|
name = 'plugin'
|
|
|
|
def ready(self):
|
|
"""The ready method is extended to initialize plugins."""
|
|
# skip loading if we run in a background thread
|
|
if not isInMainThread():
|
|
return
|
|
|
|
if not canAppAccessDatabase(allow_test=True, allow_plugins=True):
|
|
logger.info("Skipping plugin loading sequence") # pragma: no cover
|
|
else:
|
|
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
|
|
|
|
# get plugins and init them
|
|
registry.plugin_modules = registry.collect_plugins()
|
|
registry.load_plugins()
|
|
|
|
# drop out of maintenance
|
|
# makes sure we did not have an error in reloading and maintenance is still active
|
|
set_maintenance_mode(False)
|