Supervisor compiles

Signed-off-by: John Howard <jhoward@microsoft.com>
This commit is contained in:
John Howard 2016-02-25 19:18:10 -08:00
parent cc00a35bfc
commit cdb5947f86
9 changed files with 129 additions and 40 deletions

View file

@ -1,3 +1,5 @@
// +build !windows
package supervisor package supervisor
import "github.com/docker/containerd/runtime" import "github.com/docker/containerd/runtime"

View file

@ -8,13 +8,13 @@ import (
type StartTask struct { type StartTask struct {
baseTask baseTask
platformStartTask
ID string ID string
BundlePath string BundlePath string
Stdout string Stdout string
Stderr string Stderr string
Stdin string Stdin string
StartResponse chan StartResponse StartResponse chan StartResponse
Checkpoint *runtime.Checkpoint
Labels []string Labels []string
} }
@ -36,9 +36,8 @@ func (s *Supervisor) start(t *StartTask) error {
Stdout: t.Stdout, Stdout: t.Stdout,
Stderr: t.Stderr, Stderr: t.Stderr,
} }
if t.Checkpoint != nil { task.setTaskCheckpoint(t)
task.Checkpoint = t.Checkpoint.Name
}
s.startTasks <- task s.startTasks <- task
ContainerCreateTimer.UpdateSince(start) ContainerCreateTimer.UpdateSince(start)
return errDeferedResponse return errDeferedResponse

View file

@ -0,0 +1,13 @@
package supervisor
import "github.com/docker/containerd/runtime"
type platformStartTask struct {
Checkpoint *runtime.Checkpoint
}
func (task *startTask) setTaskCheckpoint(t *StartTask) {
if t.Checkpoint != nil {
task.Checkpoint = t.Checkpoint.Name
}
}

View file

@ -0,0 +1,8 @@
package supervisor
type platformStartTask struct {
}
// Checkpoint not supported on Windows
func (task *startTask) setTaskCheckpoint(t *StartTask) {
}

View file

@ -0,0 +1,33 @@
package supervisor
import (
"errors"
"github.com/docker/containerd/runtime"
)
// TODO Windows: This is going to be very problematic to port to Windows.
// Windows golang has no concept of EpollEvent/EpollCtl etc as in the
// Linux implementation. @crosbymichael - Help needed.
func NewMonitor() (*Monitor, error) {
return nil, errors.New("NewMonitor not implemented on Windows")
}
type Monitor struct {
}
func (m *Monitor) Exits() chan runtime.Process {
return nil
}
func (m *Monitor) Monitor(p runtime.Process) error {
return errors.New("Monitor not implemented on Windows")
}
func (m *Monitor) Close() error {
return errors.New("Monitor Close() not implemented on Windows")
}
func (m *Monitor) start() {
}

View file

@ -216,42 +216,6 @@ func (s *Supervisor) Start() error {
return nil return nil
} }
func (s *Supervisor) handleTask(i Task) {
var err error
switch t := i.(type) {
case *AddProcessTask:
err = s.addProcess(t)
case *CreateCheckpointTask:
err = s.createCheckpoint(t)
case *DeleteCheckpointTask:
err = s.deleteCheckpoint(t)
case *StartTask:
err = s.start(t)
case *DeleteTask:
err = s.delete(t)
case *ExitTask:
err = s.exit(t)
case *ExecExitTask:
err = s.execExit(t)
case *GetContainersTask:
err = s.getContainers(t)
case *SignalTask:
err = s.signal(t)
case *StatsTask:
err = s.stats(t)
case *UpdateTask:
err = s.updateContainer(t)
case *UpdateProcessTask:
err = s.updateProcess(t)
default:
err = ErrUnknownTask
}
if err != errDeferedResponse {
i.ErrorCh() <- err
close(i.ErrorCh())
}
}
// Machine returns the machine information for which the // Machine returns the machine information for which the
// supervisor is executing on. // supervisor is executing on.
func (s *Supervisor) Machine() Machine { func (s *Supervisor) Machine() Machine {

View file

@ -0,0 +1,37 @@
package supervisor
func (s *Supervisor) handleTask(i Task) {
var err error
switch t := i.(type) {
case *AddProcessTask:
err = s.addProcess(t)
case *CreateCheckpointTask:
err = s.createCheckpoint(t)
case *DeleteCheckpointTask:
err = s.deleteCheckpoint(t)
case *StartTask:
err = s.start(t)
case *DeleteTask:
err = s.delete(t)
case *ExitTask:
err = s.exit(t)
case *ExecExitTask:
err = s.execExit(t)
case *GetContainersTask:
err = s.getContainers(t)
case *SignalTask:
err = s.signal(t)
case *StatsTask:
err = s.stats(t)
case *UpdateTask:
err = s.updateContainer(t)
case *UpdateProcessTask:
err = s.updateProcess(t)
default:
err = ErrUnknownTask
}
if err != errDeferedResponse {
i.ErrorCh() <- err
close(i.ErrorCh())
}
}

View file

@ -0,0 +1,33 @@
package supervisor
func (s *Supervisor) handleTask(i Task) {
var err error
switch t := i.(type) {
case *AddProcessTask:
err = s.addProcess(t)
case *StartTask:
err = s.start(t)
case *DeleteTask:
err = s.delete(t)
case *ExitTask:
err = s.exit(t)
case *ExecExitTask:
err = s.execExit(t)
case *GetContainersTask:
err = s.getContainers(t)
case *SignalTask:
err = s.signal(t)
case *StatsTask:
err = s.stats(t)
case *UpdateTask:
err = s.updateContainer(t)
case *UpdateProcessTask:
err = s.updateProcess(t)
default:
err = ErrUnknownTask
}
if err != errDeferedResponse {
i.ErrorCh() <- err
close(i.ErrorCh())
}
}