Skip to content

Commit 9573e82

Browse files
committed
state-svc stop should not start the service if it's not running.
1 parent 6e98313 commit 9573e82

File tree

2 files changed

+6
-13
lines changed

2 files changed

+6
-13
lines changed

cmd/state-svc/test/integration/svc_int_test.go

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -183,18 +183,6 @@ func (suite *SvcIntegrationTestSuite) TestSingleSvc() {
183183
// with due to other integration tests not always waiting for state-svc to have fully shut down before running the next test
184184
suite.Fail(fmt.Sprintf("spawning multiple state processes should only result in one more state-svc process at most, newCount: %d, oldCount: %d", newCount, oldCount))
185185
}
186-
187-
// ts.Close() has logic to stop state-svc if ts.SvcExe exists.
188-
// It does this by invoking `state-svc stop`.
189-
// However, in the event we end up with less services than anticipated, `state-svc stop` will
190-
// fail with a non-zero exit code because there is no service to stop, and this will cause a
191-
// timeout error in ts.Close().
192-
// In order to prevent this, change ts.SvcExe to something that doesn't exist.
193-
if runtime.GOOS == "windows" {
194-
cp := ts.SpawnCmd(ts.SvcExe, "stop")
195-
cp.ExpectExit()
196-
ts.SvcExe = "does-not-exist"
197-
}
198186
}
199187

200188
func (suite *SvcIntegrationTestSuite) GetNumStateSvcProcesses() int {

internal/svcctl/svcctl.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,10 +137,15 @@ func LogFileName(ipComm IPCommunicator) (string, error) {
137137
}
138138

139139
func StopServer(ipComm IPCommunicator) error {
140+
_, err := LocateHTTP(ipComm)
141+
if err != nil {
142+
return nil // service is not up and running, so nothing to do
143+
}
144+
140145
ctx, cancel := context.WithTimeout(context.Background(), commonTimeout)
141146
defer cancel()
142147

143-
err := stopAndWait(ctx, ipComm)
148+
err = stopAndWait(ctx, ipComm)
144149
var errServerDown *ipc.ServerDownError
145150
if err != nil && !errors.As(err, &errServerDown) {
146151
return errs.Wrap(err, "Cannot stop service")

0 commit comments

Comments
 (0)