Run bundler through honcho

This commit is contained in:
2025-02-15 12:15:08 +01:00
parent 2c9b72fe1d
commit 8528820d89
5 changed files with 25 additions and 11 deletions

View File

@ -1,4 +1,7 @@
import logging
import os
import subprocess
import sys
from django.conf import settings
from django.contrib.staticfiles.management.commands.runserver import (
@ -6,7 +9,7 @@ from django.contrib.staticfiles.management.commands.runserver import (
)
from django.utils.autoreload import DJANGO_AUTORELOAD_ENV
from staticfiles.processors import JSBundler, OpenApi
from staticfiles.processors import OpenApi
class Command(Runserver):
@ -15,10 +18,11 @@ class Command(Runserver):
def run(self, **options):
# OpenApi generation needs to be before the bundler
OpenApi.compile()
# Only run the bundling server when debug is enabled
# Run all other web processes but only if debug mode is enabled
# Also protects from re-launching the server if django reloads it
if os.environ.get(DJANGO_AUTORELOAD_ENV) is None and settings.DEBUG:
with JSBundler.runserver():
logging.getLogger("django").info("Running complementary processes")
with subprocess.Popen([sys.executable, "-m", "honcho", "start"]):
super().run(**options)
return
super().run(**options)