Skip to content

Commit

Permalink
Fix issue of gaper not restarting after a previous failure
Browse files Browse the repository at this point in the history
Close #8
  • Loading branch information
maxcnunes committed Nov 18, 2018
1 parent 931f377 commit 7ecf55b
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
3 changes: 2 additions & 1 deletion gaper.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
6 changes: 6 additions & 0 deletions runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ type Runner interface {
Kill() error
Errors() chan error
Exited() bool
IsRunning() bool
ExitStatus(err error) int
}

Expand Down Expand Up @@ -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
Expand Down
6 changes: 6 additions & 0 deletions testdata/mocks.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down

0 comments on commit 7ecf55b

Please sign in to comment.