logging
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -1,3 +1,4 @@
|
|||||||
**/__pycache__/*
|
**/__pycache__/*
|
||||||
venv/*
|
venv/*
|
||||||
production/*
|
production/*
|
||||||
|
test*
|
||||||
@@ -1,6 +1,7 @@
|
|||||||
from dataclasses import dataclass
|
from dataclasses import dataclass
|
||||||
import subprocess
|
import subprocess
|
||||||
import os
|
import os
|
||||||
|
from time import time
|
||||||
|
|
||||||
@dataclass
|
@dataclass
|
||||||
class DeployerRequest:
|
class DeployerRequest:
|
||||||
@@ -12,8 +13,13 @@ class DeployerRequest:
|
|||||||
DEPLOYERDIR = "/home/drm/live"
|
DEPLOYERDIR = "/home/drm/live"
|
||||||
|
|
||||||
def handle_request(rq: DeployerRequest):
|
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(
|
subprocess.Popen(
|
||||||
["sudo", "-E", "./deploy.sh"],
|
f"sudo -E ./deploy.sh > {log_file} >2 {log_file}",
|
||||||
|
shell=True,
|
||||||
env=dict(
|
env=dict(
|
||||||
os.environ,
|
os.environ,
|
||||||
DEPLOYERDIR=DEPLOYERDIR,
|
DEPLOYERDIR=DEPLOYERDIR,
|
||||||
|
|||||||
Reference in New Issue
Block a user