Add Valid command to spawner and make executors check when opening

This commit is contained in:
Alex Dadgar
2015-11-06 11:23:27 -08:00
parent bf44d3c2ed
commit 34ccda8cd1
6 changed files with 123 additions and 5 deletions

View File

@@ -285,3 +285,18 @@ func (s *Spawner) readExitCode() (int, error) {
return exitStatus.ExitCode, nil
}
// Valid checks that the state of the Spawner is valid and that a subsequent
// Wait could be called. This is useful to call when reopening a Spawner
// throught client restarts. If Valid a nil error is returned.
func (s *Spawner) Valid() error {
if s.Alive() {
return nil
}
if _, err := s.readExitCode(); err == nil {
return nil
}
return fmt.Errorf("Spawner not alive and exit code not written")
}