Skip to content

Commit

Permalink
Check if Linux service is running before trying to start or stop it (#…
Browse files Browse the repository at this point in the history
…540)

this prevents needless prompts opening up
  • Loading branch information
Jan200101 authored and AAGaming00 committed Dec 29, 2023
1 parent 41c62c3 commit 6cb545c
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions backend/decky_loader/localplatform/localplatformlinux.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,11 +125,19 @@ async def service_restart(service_name : str) -> bool:
return res.returncode == 0

async def service_stop(service_name : str) -> bool:
if not await service_active(service_name):
# Service isn't running. pretend we stopped it
return True

cmd = ["systemctl", "stop", service_name]
res = run(cmd, stdout=PIPE, stderr=STDOUT)
return res.returncode == 0

async def service_start(service_name : str) -> bool:
if await service_active(service_name):
# Service is running. pretend we started it
return True

cmd = ["systemctl", "start", service_name]
res = run(cmd, stdout=PIPE, stderr=STDOUT)
return res.returncode == 0
Expand Down

0 comments on commit 6cb545c

Please sign in to comment.