Massive speedup in executing startup_scripts #207
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The changes in this PR result in a massively reduced execution time of the startup_scripts.
What used to take minutes now takes seconds. This increases the startup time of a Netbox Docker container drastically.
The bottleneck was that
./manage.py shell
was run for every file in thestartup_scripts
folder.This command takes a while to load, because it has to initialize the whole Django context.
The new solution is that
./manage.py shell
is only loaded once. It is given a piece of python code that loads thestartup_scripts/__main__.py
file. This file contains the remaining code to execute all the startup scripts in the right order.