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,