Merge pull request #207 from netbox-community/speedup_startup_scripts

Massive speedup in executing startup_scripts
This commit is contained in:
Christian Mäder 2019-12-16 12:17:21 +01:00 committed by GitHub
commit b48de9f87e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 19 additions and 4 deletions

View File

@ -45,10 +45,7 @@ fi
if [ "$SKIP_STARTUP_SCRIPTS" == "true" ]; then if [ "$SKIP_STARTUP_SCRIPTS" == "true" ]; then
echo "↩️ Skipping startup scripts" echo "↩️ Skipping startup scripts"
else else
for script in /opt/netbox/startup_scripts/*.py; do echo "import runpy; runpy.run_path('../startup_scripts')" | ./manage.py shell --interface python
echo "⚙️ Executing '$script'"
./manage.py shell --interface python < "${script}"
done
fi fi
# copy static files # copy static files

View File

@ -0,0 +1,18 @@
#!/usr/bin/env python3
import runpy
from os import scandir
from os.path import dirname, abspath
this_dir = dirname(abspath(__file__))
def filename(f):
return f.name
with scandir(dirname(abspath(__file__))) as it:
for f in sorted(it, key = filename):
if f.name.startswith('__') or not f.is_file():
continue
print(f"Running {f.path}")
runpy.run_path(f.path)