restart function restarts later race condition
This commit is contained in:
1 parent
ea6a5ce15e
commit
10f372173f
1 file changed
+12
-2
+12
-2
@@ -104,10 +104,20 @@ class GitPull(commands.Cog):
|
|||||||
f"Restarting `{SERVICE_NAME}` — see you on the other side.",
|
f"Restarting `{SERVICE_NAME}` — see you on the other side.",
|
||||||
C_WARN,
|
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:
|
try:
|
||||||
await run_sudo_systemctl("restart")
|
proc.stdin.write(f"{SUDO_PASSWORD}\n".encode())
|
||||||
|
await proc.stdin.drain()
|
||||||
|
proc.stdin.close()
|
||||||
except Exception:
|
except Exception:
|
||||||
pass # process dies mid-call, that's expected
|
pass
|
||||||
|
|
||||||
# ── !gitpull ──────────────────────────────────────────────────────────────
|
# ── !gitpull ──────────────────────────────────────────────────────────────
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user