mirror of https://github.com/maxcnunes/gaper.git
Refactor changeRestart variable
This commit is contained in:
parent
eb4510b3fe
commit
55cf00b791
12
gaper.go
12
gaper.go
|
@ -95,7 +95,8 @@ func Run(cfg *Config) error { // nolint: gocyclo
|
|||
return fmt.Errorf("watcher error: %v", err)
|
||||
}
|
||||
|
||||
var changeRestart bool
|
||||
// flag to know if an exit was caused by a restart from a file changing
|
||||
changeRestart := false
|
||||
|
||||
go watcher.Watch()
|
||||
for {
|
||||
|
@ -109,14 +110,17 @@ func Run(cfg *Config) error { // nolint: gocyclo
|
|||
case err := <-watcher.Errors:
|
||||
return fmt.Errorf("error on watching files: %v", err)
|
||||
case err := <-runner.Errors():
|
||||
logger.Debug("Detected program exit: ", err)
|
||||
|
||||
// ignore exit by change
|
||||
if changeRestart {
|
||||
changeRestart = false
|
||||
} else {
|
||||
logger.Debug("Detected program exit: ", err)
|
||||
continue
|
||||
}
|
||||
|
||||
if err = handleProgramExit(builder, runner, err, cfg.NoRestartOn); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
default:
|
||||
time.Sleep(time.Duration(cfg.PollInterval) * time.Millisecond)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue