Skip to content

Commit

Permalink
check service status on install fisrt
Browse files Browse the repository at this point in the history
  • Loading branch information
Son Roy Almerol committed Nov 15, 2024
1 parent 5d70475 commit 31f2190
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion cmd/windows_agent/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,18 @@ func main() {
cmd := os.Args[1]
switch cmd {
case "install":
_ = s.Uninstall()
status, err := s.Status()
if err == nil {
switch status {
case service.StatusStopped:
_ = s.Uninstall()
case service.StatusRunning:
_ = s.Stop()
_ = s.Uninstall()
case service.StatusUnknown:
}
}

err = s.Install()
if err != nil {
logger.Errorf("Failed to install service: %s", err)
Expand Down

0 comments on commit 31f2190

Please sign in to comment.