Skip to content

Commit

Permalink
fix world cardinal dev not exit on compilation error
Browse files Browse the repository at this point in the history
  • Loading branch information
zulkhair committed May 2, 2024
1 parent 034511d commit 4dff44b
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions cmd/world/cardinal/dev.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,17 @@ var devCmd = &cobra.Command{
return err
}

// Start a goroutine to check cmd is stopped
go func() {
err := execCmd.Wait()
if err != nil {
logger.Error(eris.Wrap(err, "Cardinal process stopped"))
}

// if process exited, send signal to StopChan
signalCh <- syscall.SIGTERM
}()

// Start a goroutine to listen for signals
go func() {
<-signalCh
Expand Down Expand Up @@ -255,6 +266,10 @@ func stopCardinal(cmd *exec.Cmd, watch bool) error {
return nil
}

if cmd.ProcessState == nil || cmd.ProcessState.Exited() {
return nil
}

// stop the cardinal process
if runtime.GOOS == "windows" {
err := cmd.Process.Kill()
Expand Down

0 comments on commit 4dff44b

Please sign in to comment.