diff --git a/api/v1/server.go b/api/v1/server.go index 874da04..de867c8 100644 --- a/api/v1/server.go +++ b/api/v1/server.go @@ -48,7 +48,7 @@ func (s *server) createContainer(w http.ResponseWriter, r *http.Request) { http.Error(w, err.Error(), http.StatusBadRequest) return } - e := &containerd.CreateContainerEvent{ + e := &containerd.StartContainerEvent{ ID: id, BundlePath: c.BundlePath, Err: make(chan error, 1), diff --git a/container.go b/container.go index e06cc60..8b15b24 100644 --- a/container.go +++ b/container.go @@ -4,6 +4,7 @@ type Container interface { ID() string Start() error Pid() (int, error) + // Process() Process SetExited(status int) Delete() error } diff --git a/containerd/daemon.go b/containerd/daemon.go index 5eca592..5bd8aed 100644 --- a/containerd/daemon.go +++ b/containerd/daemon.go @@ -72,7 +72,6 @@ func startSignalHandler(supervisor *containerd.Supervisor, bufferSize int) { logrus.WithField("signal", s).Debug("containerd: received signal") switch s { case syscall.SIGTERM, syscall.SIGINT, syscall.SIGSTOP: - supervisor.Stop() os.Exit(0) case syscall.SIGCHLD: exits, err := reap() diff --git a/event.go b/event.go index 8e0d9dd..a70bdb2 100644 --- a/event.go +++ b/event.go @@ -18,12 +18,12 @@ func (e *ExitEvent) String() string { return "exit event" } -type CreateContainerEvent struct { +type StartContainerEvent struct { ID string BundlePath string Err chan error } -func (c *CreateContainerEvent) String() string { +func (c *StartContainerEvent) String() string { return "create container" } diff --git a/supervisor.go b/supervisor.go index 5ec57ed..c9b4041 100644 --- a/supervisor.go +++ b/supervisor.go @@ -2,15 +2,9 @@ package containerd import ( "os" - "time" "github.com/Sirupsen/logrus" "github.com/opencontainers/runc/libcontainer" - "github.com/rcrowley/go-metrics" -) - -var ( - containerStartTimer = metrics.NewTimer() ) // NewSupervisor returns an initialized Process supervisor. @@ -19,7 +13,6 @@ func NewSupervisor(stateDir string, concurrency int) (*Supervisor, error) { return nil, err } // register counters - metrics.DefaultRegistry.Register("container-start-time", containerStartTimer) runtime, err := NewRuntime(stateDir) if err != nil { return nil, err @@ -36,6 +29,7 @@ type Supervisor struct { // stateDir is the directory on the system to store container runtime state information. stateDir string + processes []Process containers map[string]Container runtime Runtime @@ -57,10 +51,8 @@ func (s *Supervisor) Start(events chan Event) error { logrus.WithField("event", evt).Debug("containerd: processing event") switch e := evt.(type) { case *ExitEvent: - logrus.WithFields(logrus.Fields{ - "pid": e.Pid, - "status": e.Status, - }).Debug("containerd: process exited") + logrus.WithFields(logrus.Fields{"pid": e.Pid, "status": e.Status}). + Debug("containerd: process exited") container, err := s.getContainerForPid(e.Pid) if err != nil { if err != errNoContainerForPid { @@ -73,8 +65,7 @@ func (s *Supervisor) Start(events chan Event) error { if err := container.Delete(); err != nil { logrus.WithField("error", err).Error("containerd: deleting container") } - case *CreateContainerEvent: - start := time.Now() + case *StartContainerEvent: container, err := s.runtime.Create(e.ID, e.BundlePath) if err != nil { e.Err <- err @@ -86,7 +77,6 @@ func (s *Supervisor) Start(events chan Event) error { continue } e.Err <- nil - containerStartTimer.UpdateSince(start) } } }() @@ -114,8 +104,3 @@ func (s *Supervisor) getContainerForPid(pid int) (Container, error) { func (s *Supervisor) SendEvent(evt Event) { s.events <- evt } - -// Stop initiates a shutdown of the supervisor killing all processes under supervision. -func (s *Supervisor) Stop() { - -}