From 35877c2762ee96a106e9f228a43e73f5ba9a48dd Mon Sep 17 00:00:00 2001 From: Daniel McCrystal Date: Wed, 8 Jan 2025 22:59:47 -0500 Subject: [PATCH] logging --- .gitignore | 3 ++- deploy.py | 8 +++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index f0edf14..e16e5e9 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ **/__pycache__/* venv/* -production/* \ No newline at end of file +production/* +test* \ No newline at end of file diff --git a/deploy.py b/deploy.py index b81e6b0..4ef8c1d 100644 --- a/deploy.py +++ b/deploy.py @@ -1,6 +1,7 @@ from dataclasses import dataclass import subprocess import os +from time import time @dataclass class DeployerRequest: @@ -12,8 +13,13 @@ class DeployerRequest: DEPLOYERDIR = "/home/drm/live" def handle_request(rq: DeployerRequest): + log_folder = f"./logs/{rq.repo}/{rq.branch}" + os.makedirs(log_folder, exist_ok=True) + log_file = f"{log_folder}/{int(time())}.log" + subprocess.Popen( - ["sudo", "-E", "./deploy.sh"], + f"sudo -E ./deploy.sh > {log_file} >2 {log_file}", + shell=True, env=dict( os.environ, DEPLOYERDIR=DEPLOYERDIR,