Skip to content

Commit

Permalink
Fixes Windows service stop
Browse files Browse the repository at this point in the history
When the Windows service stops, it immediately spawns a command line instance with the same arguments. This rebinds to the same port(s) and effectively prevents the service from stopping or restarting.
  • Loading branch information
nick-oconnor authored Jun 6, 2023
1 parent c92a9b4 commit e75975a
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions main_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,16 +111,15 @@ func main() {
inService, err := svc.IsWindowsService()
if err != nil {
os.Exit(99) // failed to determine service status
return
}

// running as service?
if inService {
err := svc.Run("cloud-sql-proxy", &windowsService{})
if err != nil {
os.Exit(100) // failed to execute service
return
}
return
}

// run as commandline
Expand Down

0 comments on commit e75975a

Please sign in to comment.