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