restart function restarts later race condition

This commit is contained in:
esef committed 2026-07-05 20:50:23 +03:00
1 parent ea6a5ce15e
commit 10f372173f
1 file changed
+12 -2
+12 -2
View File
@@ -104,10 +104,20 @@ class GitPull(commands.Cog):
f"Restarting `{SERVICE_NAME}` — see you on the other side.",
C_WARN,
))
await asyncio.sleep(0.5)
proc = await asyncio.create_subprocess_exec(
"sudo", "-S", "systemctl", "restart", SERVICE_NAME,
stdin=asyncio.subprocess.PIPE,
stdout=asyncio.subprocess.DEVNULL,
stderr=asyncio.subprocess.DEVNULL,
)
if SUDO_PASSWORD:
try:
await run_sudo_systemctl("restart")
proc.stdin.write(f"{SUDO_PASSWORD}\n".encode())
await proc.stdin.drain()
proc.stdin.close()
except Exception:
pass # process dies mid-call, that's expected
pass
# ── !gitpull ──────────────────────────────────────────────────────────────