Add restart recovery logic.

Signed-off-by: Lantao Liu <lantaol@google.com>
This commit is contained in:
Lantao Liu
2017-09-04 02:47:58 +00:00
parent 5dbba596e6
commit cc1b0b6709
14 changed files with 543 additions and 34 deletions

View File

@@ -136,6 +136,17 @@ func WithRootDir(root string) Opts {
}
}
// WithFIFOs specifies existing fifos for the container io.
func WithFIFOs(dir, stdin, stdout, stderr string) Opts {
return func(c *ContainerIO) error {
c.dir = dir
c.stdinPath = stdin
c.stdoutPath = stdout
c.stderrPath = stderr
return nil
}
}
// NewContainerIO creates container io.
func NewContainerIO(id string, opts ...Opts) (*ContainerIO, error) {
c := &ContainerIO{
@@ -149,6 +160,10 @@ func NewContainerIO(id string, opts ...Opts) (*ContainerIO, error) {
return nil, err
}
}
if c.dir != "" {
// Return if fifos are already set.
return c, nil
}
fifos, err := newFifos(c.root, id)
if err != nil {
return nil, err