Skip to content

Commit

Permalink
fix winsw command by reinstalling
Browse files Browse the repository at this point in the history
  • Loading branch information
et-nik committed Feb 27, 2024
1 parent 79f7a44 commit 1a2a9cb
Showing 1 changed file with 12 additions and 14 deletions.
26 changes: 12 additions & 14 deletions internal/processmanager/winsw.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ const (
servicePrefix = "gameapServer"

outputSizeLimit = 30000

errorCodeCannotStart = 1053
)

type WinSW struct {
Expand Down Expand Up @@ -154,21 +156,17 @@ func (pm *WinSW) command(

result, err = pm.runWinSWCommand(ctx, command, server, out)
if err != nil {
if command == "start" {
logger.Warn(ctx, errors.WithMessage(err, "failed to run command"))
result, err = pm.tryFixReinstallService(ctx, server, out)
if err != nil {
return domain.ErrorResult, errors.WithMessage(err, "failed to try fix by reinstalling service")
}
if result != domain.SuccessResult {
return domain.ErrorResult, errors.New("failed to try fix by reinstalling service")
}
return domain.ErrorResult, errors.WithMessage(err, "failed to exec command")
}

result, err = pm.runWinSWCommand(ctx, command, server, out)
if err != nil {
return domain.ErrorResult, errors.WithMessage(err, "failed to exec command")
}
} else {
if result == errorCodeCannotStart && command == "start" {
_, err = pm.tryFixReinstallService(ctx, server, out)
if err != nil {
return domain.ErrorResult, errors.WithMessage(err, "failed to try fix by reinstalling service")
}

result, err = pm.runWinSWCommand(ctx, command, server, out)
if err != nil {
return domain.ErrorResult, errors.WithMessage(err, "failed to exec command")
}
}
Expand Down

0 comments on commit 1a2a9cb

Please sign in to comment.