Skip to content

Commit

Permalink
fix(windows): refactor start stop agent without relying on $PSCulture…
Browse files Browse the repository at this point in the history
… = "en-US"

fixes aws#604
  • Loading branch information
qoomon authored Dec 6, 2024
1 parent f6ab670 commit 1ec8754
Showing 1 changed file with 2 additions and 12 deletions.
14 changes: 2 additions & 12 deletions agent/setupcli/managers/servicemanagers/windowsmanager.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,10 @@ func (m *windowsManager) StartAgent() error {
if exitError, ok := err.(*exec.ExitError); ok {
ec := exitError.ExitCode()
// NET HELPMSG 2182 : The requested service has already been started.
if ec == 2182 {
if ec == 2 {
return nil
}
}
output = strings.ToLower(output)
if strings.Contains(output, "service has already been started") {
// service already running
return nil
}
return fmt.Errorf("windows: failed to start agent with output '%s' and error: %v", output, err)
}
return nil
Expand All @@ -64,15 +59,10 @@ func (m *windowsManager) StopAgent() error {
if exitError, ok := err.(*exec.ExitError); ok {
ec := exitError.ExitCode()
//NET HELPMSG 3521 : The *** service is not started.
if ec == 3521 {
if ec == 2 {
return nil
}
}
output = strings.ToLower(output)
if strings.Contains(output, "service is not started") {
// Service is already stopped
return nil
}
return fmt.Errorf("windows: failed to stop agent with output '%s' and error: %v", output, err)
}
return nil
Expand Down

0 comments on commit 1ec8754

Please sign in to comment.