Skip to content

Commit 8be8731

Browse files
committed
Fix install not restarting running service
systemctl start is a no-op when the service is already running, so upgrades left the old version in memory. Now detects a running service and issues restart instead.
1 parent 6275e86 commit 8be8731

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

src/devils_advocate/cli.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -626,6 +626,8 @@ def install_cmd(port, no_start, force):
626626
service_exists,
627627
systemctl_daemon_reload,
628628
systemctl_enable,
629+
systemctl_is_active,
630+
systemctl_restart,
629631
systemctl_start,
630632
write_service_file,
631633
)
@@ -672,7 +674,10 @@ def install_cmd(port, no_start, force):
672674
systemctl_daemon_reload()
673675
systemctl_enable()
674676
if not no_start:
675-
systemctl_start()
677+
if systemctl_is_active():
678+
systemctl_restart()
679+
else:
680+
systemctl_start()
676681
except RuntimeError as e:
677682
console.print(f"[red]Error:[/red] {e}")
678683
sys.exit(1)

src/devils_advocate/service.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,11 @@ def systemctl_start() -> None:
146146
_run_systemctl("start", SERVICE_NAME)
147147

148148

149+
def systemctl_restart() -> None:
150+
"""Run ``systemctl --user restart dvad-gui.service``."""
151+
_run_systemctl("restart", SERVICE_NAME)
152+
153+
149154
def systemctl_stop() -> None:
150155
"""Run ``systemctl --user stop dvad-gui.service``."""
151156
_run_systemctl("stop", SERVICE_NAME)

0 commit comments

Comments
 (0)