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