Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(windows): refactor start and stop agent to not rely on $PSCulture #606

Open
wants to merge 1 commit into
base: mainline
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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