mirror of
https://github.com/ramvignesh-b/pi-ku.git
synced 2026-05-04 08:56:52 +00:00
refactor: centralize log directory path handling and remove redundant log directory creation in Dockerfile
This commit is contained in:
@@ -10,9 +10,6 @@ RUN uv sync --frozen --no-dev
|
|||||||
|
|
||||||
COPY . .
|
COPY . .
|
||||||
|
|
||||||
# Make the temp log dir writable since server is running rootless
|
|
||||||
RUN mkdir -p /app/logs && chmod -R 777 /app/logs
|
|
||||||
|
|
||||||
EXPOSE 8000
|
EXPOSE 8000
|
||||||
|
|
||||||
CMD ["sh", "-c", "uv run manage.py migrate && uv run gunicorn --bind 0.0.0.0:8000 --access-logfile - --error-logfile - --capture-output --log-level debug config.wsgi:application"]
|
CMD ["sh", "-c", "uv run manage.py migrate && uv run gunicorn --bind 0.0.0.0:8000 --access-logfile - --error-logfile - --capture-output --log-level debug config.wsgi:application"]
|
||||||
|
|||||||
@@ -1,5 +1,12 @@
|
|||||||
|
from pathlib import Path
|
||||||
|
|
||||||
import structlog
|
import structlog
|
||||||
|
|
||||||
|
BASE_DIR = Path(__file__).resolve().parent.parent
|
||||||
|
LOGS_DIR = BASE_DIR / "logs"
|
||||||
|
|
||||||
|
LOGS_DIR.mkdir(parents=True, exist_ok=True)
|
||||||
|
|
||||||
structlog.configure(
|
structlog.configure(
|
||||||
processors=[
|
processors=[
|
||||||
structlog.contextvars.merge_contextvars,
|
structlog.contextvars.merge_contextvars,
|
||||||
@@ -41,22 +48,22 @@ LOGGING = {
|
|||||||
},
|
},
|
||||||
"json_file": {
|
"json_file": {
|
||||||
"class": "logging.handlers.WatchedFileHandler",
|
"class": "logging.handlers.WatchedFileHandler",
|
||||||
"filename": "logs/json.log",
|
"filename": LOGS_DIR / "json.log",
|
||||||
"formatter": "json_formatter",
|
"formatter": "json_formatter",
|
||||||
},
|
},
|
||||||
"flat_line_file": {
|
"flat_line_file": {
|
||||||
"class": "logging.handlers.WatchedFileHandler",
|
"class": "logging.handlers.WatchedFileHandler",
|
||||||
"filename": "logs/flat_line.log",
|
"filename": LOGS_DIR / "flat_line.log",
|
||||||
"formatter": "key_value",
|
"formatter": "key_value",
|
||||||
},
|
},
|
||||||
"letters_log": {
|
"letters_log": {
|
||||||
"class": "logging.handlers.WatchedFileHandler",
|
"class": "logging.handlers.WatchedFileHandler",
|
||||||
"filename": "logs/letters.log",
|
"filename": LOGS_DIR / "letters.log",
|
||||||
"formatter": "key_value",
|
"formatter": "key_value",
|
||||||
},
|
},
|
||||||
"scheduler_log": {
|
"scheduler_log": {
|
||||||
"class": "logging.handlers.WatchedFileHandler",
|
"class": "logging.handlers.WatchedFileHandler",
|
||||||
"filename": "logs/scheduler.log",
|
"filename": LOGS_DIR / "scheduler.log",
|
||||||
"formatter": "key_value",
|
"formatter": "key_value",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user