From 6841d96455f993e2848422f7eb86b7437da6b1b5 Mon Sep 17 00:00:00 2001 From: Sli Date: Sat, 15 Feb 2025 17:58:07 +0100 Subject: [PATCH] Enable honcho on non debug --- Procfile | 2 +- docs/tutorial/structure.md | 6 ++++-- staticfiles/management/commands/runserver.py | 10 ++++++++-- 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/Procfile b/Procfile index 857b2f2d..f3ce1a69 100644 --- a/Procfile +++ b/Procfile @@ -1 +1 @@ -bundler: npm run serve \ No newline at end of file +bundler: npm run $BUNDLER_MODE \ No newline at end of file diff --git a/docs/tutorial/structure.md b/docs/tutorial/structure.md index aff331d2..4ba0077e 100644 --- a/docs/tutorial/structure.md +++ b/docs/tutorial/structure.md @@ -80,6 +80,7 @@ sith/ ├── pyproject.toml (30) ├── .venv/ (31) ├── .python-version (32) +├── Procfile (33) └── README.md ``` @@ -136,7 +137,8 @@ sith/ de certaines d'entre elles. 31. Dossier d'environnement virtuel généré par uv 32. Fichier qui contrôle quelle version de python utiliser pour le projet - +33. Fichier qui contrôle les services additionnels à lancer + avec le serveur de développement ## L'application principale @@ -220,4 +222,4 @@ comme suit : L'organisation peut éventuellement être un peu différente pour certaines applications, mais le principe -général est le même. \ No newline at end of file +général est le même. diff --git a/staticfiles/management/commands/runserver.py b/staticfiles/management/commands/runserver.py index 8614d8b9..5fc80a64 100644 --- a/staticfiles/management/commands/runserver.py +++ b/staticfiles/management/commands/runserver.py @@ -20,9 +20,15 @@ class Command(Runserver): OpenApi.compile() # 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: + if os.environ.get(DJANGO_AUTORELOAD_ENV) is None: logging.getLogger("django").info("Running complementary processes") - with subprocess.Popen([sys.executable, "-m", "honcho", "start"]): + with subprocess.Popen( + [sys.executable, "-m", "honcho", "start"], + env={ + **os.environ, + **{"BUNDLER_MODE": "serve" if settings.DEBUG else "compile"}, + }, + ): super().run(**options) return super().run(**options)