diff --git a/LICENSE.code b/LICENSE.code index c7a3f0cfd..8f3fee627 100644 --- a/LICENSE.code +++ b/LICENSE.code @@ -176,7 +176,7 @@ END OF TERMS AND CONDITIONS - Copyright 2013-2015 Docker, Inc. + Copyright 2013-2016 Docker, Inc. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/MAINTAINERS b/MAINTAINERS index 3bb039b46..77c5fa7b3 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -9,10 +9,12 @@ # This file is compiled into the MAINTAINERS file in docker/opensource. # [Org] - [Org."Core maintainers"] - people = [ - "crosbymichael", - ] + [Org."Core maintainers"] + people = [ + "crosbymichael", + "tonistiigi", + "mlaventure", + ] [people] @@ -22,7 +24,18 @@ # ADD YOURSELF HERE IN ALPHABETICAL ORDER - [people.crosbymichael] - Name = "Michael Crosby" - Email = "crosbymichael@gmail.com" - GitHub = "crosbymichael" + [people.crosbymichael] + Name = "Michael Crosby" + Email = "crosbymichael@gmail.com" + GitHub = "crosbymichael" + + [people.tonistiigi] + Name = "Tõnis Tiigi" + Email = "tonis@docker.com" + GitHub = "tonistiigi" + + [people.mlaventure] + Name = "Kenfe-Mickaël Laventure" + Email = "mickael.laventure@docker.com" + GitHub = "mlaventure" + diff --git a/README.md b/README.md index 78e4312c4..10ae42a3e 100644 --- a/README.md +++ b/README.md @@ -1,18 +1,9 @@ # containerd Containerd is a daemon to control runC, built for performance and density. -Containerd leverages runC advanced features such as seccomp and user namespace support as well +Containerd leverages runC's advanced features such as seccomp and user namespace support as well as checkpoint and restore for cloning and live migration of containers. -#### Status - -*alpha* - -What does alpha, beta, etc mean? -* alpha - not feature complete -* beta - feature complete but needs testing -* prod ready - ready for production - ## Docs For more documentation on various subjects refer to the `/docs` directory in this repository. @@ -348,7 +339,7 @@ commit automatically with `git commit -s`. ## Copyright and license -Copyright © 2015 Docker, Inc. All rights reserved, except as follows. Code +Copyright © 2016 Docker, Inc. All rights reserved, except as follows. Code is released under the Apache 2.0 license. The README.md file, and files in the "docs" folder are licensed under the Creative Commons Attribution 4.0 International License under the terms and conditions set forth in the file diff --git a/containerd/main.go b/containerd/main.go index d8d54e876..1c9ec1456 100644 --- a/containerd/main.go +++ b/containerd/main.go @@ -4,7 +4,9 @@ import ( "fmt" "net" "os" + "os/signal" "sync" + "syscall" "time" "google.golang.org/grpc" @@ -14,6 +16,7 @@ import ( "github.com/docker/containerd" "github.com/docker/containerd/api/grpc/server" "github.com/docker/containerd/api/grpc/types" + "github.com/docker/containerd/osutils" "github.com/docker/containerd/supervisor" ) @@ -80,7 +83,11 @@ func main() { func daemon(address, stateDir string, concurrency int, runtimeName string) error { // setup a standard reaper so that we don't leave any zombies if we are still alive // this is just good practice because we are spawning new processes - go reapProcesses() + s := make(chan os.Signal, 2048) + signal.Notify(s, syscall.SIGCHLD, syscall.SIGTERM, syscall.SIGINT) + if err := osutils.SetSubreaper(1); err != nil { + logrus.WithField("error", err).Error("containerd: set subpreaper") + } sv, err := supervisor.New(stateDir, runtimeName) if err != nil { return err @@ -94,17 +101,42 @@ func daemon(address, stateDir string, concurrency int, runtimeName string) error if err := sv.Start(); err != nil { return err } - if err := os.RemoveAll(address); err != nil { - return err - } - l, err := net.Listen(defaultListenType, address) + server, err := startServer(address, sv) if err != nil { return err } + for ss := range s { + switch ss { + case syscall.SIGCHLD: + if _, err := osutils.Reap(); err != nil { + logrus.WithField("error", err).Warn("containerd: reap child processes") + } + default: + logrus.Infof("stopping containerd after receiving %s", ss) + server.Stop() + os.Exit(0) + } + } + return nil +} + +func startServer(address string, sv *supervisor.Supervisor) (*grpc.Server, error) { + if err := os.RemoveAll(address); err != nil { + return nil, err + } + l, err := net.Listen(defaultListenType, address) + if err != nil { + return nil, err + } s := grpc.NewServer() types.RegisterAPIServer(s, server.NewServer(sv)) - logrus.Debugf("containerd: grpc api on %s", address) - return s.Serve(l) + go func() { + logrus.Debugf("containerd: grpc api on %s", address) + if err := s.Serve(l); err != nil { + logrus.WithField("error", err).Fatal("containerd: serve grpc") + } + }() + return s, nil } // getDefaultID returns the hostname for the instance host diff --git a/containerd/main_linux.go b/containerd/main_linux.go index 2abf327ed..49fc790ce 100644 --- a/containerd/main_linux.go +++ b/containerd/main_linux.go @@ -4,7 +4,6 @@ import ( "log" "net" "os" - "os/signal" "runtime" "syscall" "time" @@ -62,19 +61,6 @@ func checkLimits() error { return nil } -func reapProcesses() { - s := make(chan os.Signal, 2048) - signal.Notify(s, syscall.SIGCHLD) - if err := osutils.SetSubreaper(1); err != nil { - logrus.WithField("error", err).Error("containerd: set subpreaper") - } - for range s { - if _, err := osutils.Reap(); err != nil { - logrus.WithField("error", err).Error("containerd: reap child processes") - } - } -} - func processMetrics() { var ( g = metrics.NewGauge() diff --git a/containerd/main_windows.go b/containerd/main_windows.go deleted file mode 100644 index 06c5750d9..000000000 --- a/containerd/main_windows.go +++ /dev/null @@ -1,29 +0,0 @@ -package main - -import ( - "os" - - "github.com/codegangsta/cli" -) - -var defaultStateDir = os.Getenv("PROGRAMDATA") + `\docker\containerd` - -const ( - defaultListenType = "tcp" - defaultGRPCEndpoint = "localhost:2377" -) - -func appendPlatformFlags() { -} - -// TODO Windows: May be able to factor out entirely -func checkLimits() error { - return nil -} - -// No idea how to implement this on Windows. -func reapProcesses() { -} - -func setAppBefore(app *cli.App) { -} diff --git a/version.go b/version.go index 0976245a9..ad932ba1d 100644 --- a/version.go +++ b/version.go @@ -1,5 +1,5 @@ package containerd -const Version = "0.0.5" +const Version = "0.1.0" var GitCommit = ""