Apply review comments

This commit is contained in:
2025-02-26 14:37:22 +01:00
parent e542fe11b9
commit 728ad157e9
4 changed files with 26 additions and 6 deletions

View File

@ -2,6 +2,7 @@ import logging
import signal
import subprocess
import sys
from pathlib import Path
import psutil
@ -40,7 +41,7 @@ def is_composer_running() -> bool:
return False
def start_composer(procfile: str):
def start_composer(procfile: Path):
"""Starts the composer and stores the PID as an environment variable
This allows for running smoothly with the django reloader
"""
@ -51,7 +52,7 @@ def start_composer(procfile: str):
)
return
process = subprocess.Popen(
[sys.executable, "-m", "honcho", "-f", procfile, "start"],
[sys.executable, "-m", "honcho", "-f", str(procfile), "start"],
)
write_pid(process.pid)

View File

@ -50,11 +50,22 @@ from .honeypot import custom_honeypot_error
env = Env()
env.read_env()
@env.parser_for("optional_file")
def optional_file_parser(value: str) -> Path | None:
if not value:
return None
path = Path(value)
if not path.is_file():
return None
return path
BASE_DIR = Path(__file__).parent.parent.resolve()
# Composer settings
PROCFILE_RUNSERVER = env.str("PROCFILE_RUNSERVER", None)
PROCFILE_PYTEST = env.str("PROCFILE_PYTEST", None)
PROCFILE_RUNSERVER = env.optional_file("PROCFILE_RUNSERVER", None)
PROCFILE_PYTEST = env.optional_file("PROCFILE_PYTEST", 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")