mirror of
https://github.com/ae-utbm/sith.git
synced 2025-03-09 23:07:11 +00:00
Only run full procfile on runserver
This commit is contained in:
parent
728ad157e9
commit
75c4c55a32
@ -12,6 +12,6 @@ REDIS_PORT=7963
|
||||
CACHE_URL=redis://127.0.0.1:${REDIS_PORT}/0
|
||||
|
||||
# Used to select which other services to run alongside
|
||||
# runserver and pytest
|
||||
PROCFILE_RUNSERVER=Procfile.dev
|
||||
PROCFILE_PYTEST=Procfile.pytest
|
||||
# manage.py, pytest and runserver
|
||||
PROCFILE_FULL=Procfile.full
|
||||
PROCFILE_MINIMAL=Procfile.minimal
|
||||
|
1
.gitignore
vendored
1
.gitignore
vendored
@ -19,6 +19,7 @@ sith/search_indexes/
|
||||
coverage_report/
|
||||
node_modules/
|
||||
.env
|
||||
*.pid
|
||||
|
||||
# compiled documentation
|
||||
site/
|
||||
|
@ -88,8 +88,8 @@ tous ces services sont déjà configurés.
|
||||
Pour désactiver Honcho il suffit de ne sélectionner aucun `PROCFILE_` dans la config.
|
||||
|
||||
```dotenv
|
||||
PROCFILE_RUNSERVER=
|
||||
PROCFILE_PYTEST=
|
||||
PROCFILE_FULL=
|
||||
PROCFILE_MINIMAL=
|
||||
```
|
||||
|
||||
!!! note
|
||||
|
@ -82,8 +82,8 @@ sith/
|
||||
├── pyproject.toml (31)
|
||||
├── .venv/ (32)
|
||||
├── .python-version (33)
|
||||
├── Procfile.dev (34)
|
||||
├── Procfile.pytest (35)
|
||||
├── Procfile.full (34)
|
||||
├── Procfile.minimal (35)
|
||||
└── README.md
|
||||
```
|
||||
</div>
|
||||
@ -143,9 +143,9 @@ sith/
|
||||
32. Dossier d'environnement virtuel généré par uv
|
||||
33. Fichier qui contrôle quelle version de python utiliser pour le projet
|
||||
34. Fichier qui contrôle les services additionnels à lancer
|
||||
avec le serveur de développement
|
||||
avec le serveur de développement. Serveurs + gestion des statics.
|
||||
35. Fichier qui contrôle les services additionnels à lancer
|
||||
avec pytest
|
||||
avec les autres commandes (pytest, shell…). Serveurs uniquement.
|
||||
|
||||
## L'application principale
|
||||
|
||||
|
@ -21,7 +21,7 @@ import sys
|
||||
from django.utils.autoreload import DJANGO_AUTORELOAD_ENV
|
||||
|
||||
from sith.composer import start_composer, stop_composer
|
||||
from sith.settings import PROCFILE_RUNSERVER
|
||||
from sith.settings import PROCFILE_FULL, PROCFILE_MINIMAL
|
||||
|
||||
if __name__ == "__main__":
|
||||
logging.basicConfig(encoding="utf-8", level=logging.INFO)
|
||||
@ -30,8 +30,9 @@ if __name__ == "__main__":
|
||||
|
||||
from django.core.management import execute_from_command_line
|
||||
|
||||
if os.environ.get(DJANGO_AUTORELOAD_ENV) is None and PROCFILE_RUNSERVER is not None:
|
||||
start_composer(PROCFILE_RUNSERVER)
|
||||
procfile = PROCFILE_FULL if sys.argv[1] == "runserver" else PROCFILE_MINIMAL
|
||||
if os.environ.get(DJANGO_AUTORELOAD_ENV) is None and procfile is not None:
|
||||
start_composer(procfile)
|
||||
_ = atexit.register(stop_composer)
|
||||
|
||||
execute_from_command_line(sys.argv)
|
||||
|
@ -3,7 +3,7 @@ import atexit
|
||||
import pytest
|
||||
|
||||
from .composer import start_composer, stop_composer
|
||||
from .settings import PROCFILE_PYTEST
|
||||
from .settings import PROCFILE_MINIMAL
|
||||
|
||||
# it's the first hook loaded by pytest and can only
|
||||
# be defined in a proper pytest plugin
|
||||
@ -15,6 +15,6 @@ from .settings import PROCFILE_PYTEST
|
||||
@pytest.hookimpl(tryfirst=True)
|
||||
def pytest_load_initial_conftests(early_config, parser, args):
|
||||
"""Hook that loads the composer before the pytest-django plugin"""
|
||||
if PROCFILE_PYTEST is not None:
|
||||
start_composer(PROCFILE_PYTEST)
|
||||
if PROCFILE_MINIMAL is not None:
|
||||
start_composer(PROCFILE_MINIMAL)
|
||||
_ = atexit.register(stop_composer)
|
||||
|
@ -64,8 +64,8 @@ def optional_file_parser(value: str) -> Path | None:
|
||||
BASE_DIR = Path(__file__).parent.parent.resolve()
|
||||
|
||||
# Composer settings
|
||||
PROCFILE_RUNSERVER = env.optional_file("PROCFILE_RUNSERVER", None)
|
||||
PROCFILE_PYTEST = env.optional_file("PROCFILE_PYTEST", None)
|
||||
PROCFILE_FULL = env.optional_file("PROCFILE_FULL", None)
|
||||
PROCFILE_MINIMAL = env.optional_file("PROCFILE_MINIMAL", None)
|
||||
|
||||
## File path used to avoid running the composer multiple times at the same time
|
||||
COMPOSER_PID_PATH = env.path("COMPOSER_PID_PATH", BASE_DIR / "composer.pid")
|
||||
|
Loading…
x
Reference in New Issue
Block a user