more updates

This commit is contained in:
2025-07-30 21:57:31 -04:00
parent 93954f3190
commit 5d71c964b7
4 changed files with 46 additions and 14 deletions

View File

@@ -16,7 +16,10 @@ class DeployerRequest:
DEPLOYERDIR = "/home/drm/live"
BASE_PORT = 3001
config = {"games": {"user": "drm", "repo": "games", "branch": "prod"}}
config = {
"deployer": ("drm", "deployer", "main"),
"games": ("drm", "games", "prod"),
}
by_branch = {
(user, repo, branch): {"domain": domain, "port": BASE_PORT + i}
for i, (domain, (user, repo, branch)) in enumerate(config.items())
@@ -25,18 +28,22 @@ by_branch = {
def handle_request(rq: DeployerRequest):
if (rq.user, rq.repo, rq.branch) not in by_branch:
print(
f"{rq.user}/{rq.repo}/{rq.branch} is not registered in the deployer config"
)
print(by_branch)
return
domain, port = itemgetter("domain", "port")(
by_branch[(rq.user, rq.repo, rq.branch)]
)
deployment_id = int(time())
deployment_id = str(int(time()))
domain_dir = f"{DEPLOYERDIR}/{domain}"
deployment_dir = f"{domain_dir}/{deployment_id}"
os.makedirs(deployment_dir, exist_ok=True)
logs_dir = f"{domain_dir}/{deployment_id}"
os.makedirs(logs_dir, exist_ok=True)
build_log = f"{deployment_dir}/build.log"
build_log = f"{logs_dir}/build.log"
subprocess.Popen(
["./deploy.sh"],
@@ -47,11 +54,12 @@ def handle_request(rq: DeployerRequest):
env=dict(
os.environ,
DOMAIN=domain,
DEPLOYMENT_DIR=deployment_dir,
DOMAIN_DIR=domain_dir,
LOGS_DIR=logs_dir,
USER=rq.user,
REPO=rq.repo,
BRANCH=rq.branch,
COMMIT_HASH=rq.commit_hash,
PORT=port,
PORT=str(port),
),
)