Fix issue of gaper not restarting after a previous failure

Close #8
This commit is contained in:
Max Claus Nunes 2018-11-18 12:41:08 -02:00
parent 931f3778a8
commit 7ecf55b3f6
3 changed files with 14 additions and 1 deletions

View File

@ -103,7 +103,8 @@ func run(cfg *Config, chOSSiginal chan os.Signal, builder Builder, runner Runner
continue
}
changeRestart = true
changeRestart = runner.IsRunning()
if err := restart(builder, runner); err != nil {
return err
}

View File

@ -23,6 +23,7 @@ type Runner interface {
Kill() error
Errors() chan error
Exited() bool
IsRunning() bool
ExitStatus(err error) int
}
@ -108,6 +109,11 @@ func (r *runner) Exited() bool {
return r.command != nil && r.command.ProcessState != nil && r.command.ProcessState.Exited()
}
// IsRunning returns if the process is running
func (r *runner) IsRunning() bool {
return r.command != nil && r.command.Process != nil && r.command.Process.Pid > 0
}
// Errors get errors occurred during the build
func (r *runner) Errors() chan error {
return r.errors

6
testdata/mocks.go vendored
View File

@ -57,6 +57,12 @@ func (m *MockRunner) Exited() bool {
return args.Bool(0)
}
// IsRunning ...
func (m *MockRunner) IsRunning() bool {
args := m.Called()
return args.Bool(0)
}
// ExitStatus ...
func (m *MockRunner) ExitStatus(err error) int {
args := m.Called()