From 88535421820ceff678aeca42c92f03379c1f493b Mon Sep 17 00:00:00 2001 From: Egor Matveev Date: Sat, 7 Jun 2025 13:23:40 +0300 Subject: [PATCH] fix --- main.py | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/main.py b/main.py index 8497e15..240a036 100644 --- a/main.py +++ b/main.py @@ -42,22 +42,22 @@ def update_host(host: str) -> bool: if not container_name: print("No nginx container") return False - + gen_command = f"docker exec {container_name} certbot --nginx --email emmtvv@gmail.com --agree-tos --non-interactive -d \"{host}\"" print(gen_command) - + gen_cert = call(gen_command) if gen_cert.code != 0: print(f"failed generating certificate: {gen_cert.err}") print("Here is the log") print(call(f"docker exec {container_name} cat /var/log/letsencrypt/letsencrypt.log").out) return False - + fullchain_command = call(f"docker exec {container_name} cat /etc/letsencrypt/live/{host}/fullchain.pem") if fullchain_command.code != 0: print(f"failed getting fullchain: {fullchain_command.err}") return True - + privkey_command = call(f"docker exec {container_name} cat /etc/letsencrypt/live/{host}/privkey.pem") if privkey_command.code != 0: print(f"failed getting fullchain: {privkey_command.err}") @@ -83,10 +83,9 @@ while True: updated = True if updated: if os.getenv("STAGE") == "development": - container_id_run = call(f"echo $(docker ps -q -f name=infra-development_nginx)") - result = call(f"docker restart {container_id_run.out}") + container_id_run = call(f"echo $(docker ps -q -f name=infra-development_nginx)").out else: - result = call("docker service update --force infra_nginx") + container_id_run = call(f"echo $(docker ps -q -f name=infra_nginx)").out + print(call("docker exec {container_id_run} python3 prepare.py && nginx -s reload").out) - print(result.err, result.out) time.sleep(30)