Merge pull request #144 from docker/handle-term
Handle term signals and update documentation
This commit is contained in:
commit
54c213e8a7
7 changed files with 64 additions and 71 deletions
|
@ -176,7 +176,7 @@
|
||||||
|
|
||||||
END OF TERMS AND CONDITIONS
|
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");
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
you may not use this file except in compliance with the License.
|
you may not use this file except in compliance with the License.
|
||||||
|
|
13
MAINTAINERS
13
MAINTAINERS
|
@ -12,6 +12,8 @@
|
||||||
[Org."Core maintainers"]
|
[Org."Core maintainers"]
|
||||||
people = [
|
people = [
|
||||||
"crosbymichael",
|
"crosbymichael",
|
||||||
|
"tonistiigi",
|
||||||
|
"mlaventure",
|
||||||
]
|
]
|
||||||
|
|
||||||
[people]
|
[people]
|
||||||
|
@ -26,3 +28,14 @@
|
||||||
Name = "Michael Crosby"
|
Name = "Michael Crosby"
|
||||||
Email = "crosbymichael@gmail.com"
|
Email = "crosbymichael@gmail.com"
|
||||||
GitHub = "crosbymichael"
|
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"
|
||||||
|
|
||||||
|
|
13
README.md
13
README.md
|
@ -1,18 +1,9 @@
|
||||||
# containerd
|
# containerd
|
||||||
|
|
||||||
Containerd is a daemon to control runC, built for performance and density.
|
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.
|
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
|
## Docs
|
||||||
|
|
||||||
For more documentation on various subjects refer to the `/docs` directory in this repository.
|
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 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
|
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
|
"docs" folder are licensed under the Creative Commons Attribution 4.0
|
||||||
International License under the terms and conditions set forth in the file
|
International License under the terms and conditions set forth in the file
|
||||||
|
|
|
@ -4,7 +4,9 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"net"
|
"net"
|
||||||
"os"
|
"os"
|
||||||
|
"os/signal"
|
||||||
"sync"
|
"sync"
|
||||||
|
"syscall"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"google.golang.org/grpc"
|
"google.golang.org/grpc"
|
||||||
|
@ -14,6 +16,7 @@ import (
|
||||||
"github.com/docker/containerd"
|
"github.com/docker/containerd"
|
||||||
"github.com/docker/containerd/api/grpc/server"
|
"github.com/docker/containerd/api/grpc/server"
|
||||||
"github.com/docker/containerd/api/grpc/types"
|
"github.com/docker/containerd/api/grpc/types"
|
||||||
|
"github.com/docker/containerd/osutils"
|
||||||
"github.com/docker/containerd/supervisor"
|
"github.com/docker/containerd/supervisor"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -80,7 +83,11 @@ func main() {
|
||||||
func daemon(address, stateDir string, concurrency int, runtimeName string) error {
|
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
|
// 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
|
// 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)
|
sv, err := supervisor.New(stateDir, runtimeName)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
@ -94,17 +101,42 @@ func daemon(address, stateDir string, concurrency int, runtimeName string) error
|
||||||
if err := sv.Start(); err != nil {
|
if err := sv.Start(); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if err := os.RemoveAll(address); err != nil {
|
server, err := startServer(address, sv)
|
||||||
return err
|
|
||||||
}
|
|
||||||
l, err := net.Listen(defaultListenType, address)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
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()
|
s := grpc.NewServer()
|
||||||
types.RegisterAPIServer(s, server.NewServer(sv))
|
types.RegisterAPIServer(s, server.NewServer(sv))
|
||||||
|
go func() {
|
||||||
logrus.Debugf("containerd: grpc api on %s", address)
|
logrus.Debugf("containerd: grpc api on %s", address)
|
||||||
return s.Serve(l)
|
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
|
// getDefaultID returns the hostname for the instance host
|
||||||
|
|
|
@ -4,7 +4,6 @@ import (
|
||||||
"log"
|
"log"
|
||||||
"net"
|
"net"
|
||||||
"os"
|
"os"
|
||||||
"os/signal"
|
|
||||||
"runtime"
|
"runtime"
|
||||||
"syscall"
|
"syscall"
|
||||||
"time"
|
"time"
|
||||||
|
@ -62,19 +61,6 @@ func checkLimits() error {
|
||||||
return nil
|
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() {
|
func processMetrics() {
|
||||||
var (
|
var (
|
||||||
g = metrics.NewGauge()
|
g = metrics.NewGauge()
|
||||||
|
|
|
@ -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) {
|
|
||||||
}
|
|
|
@ -1,5 +1,5 @@
|
||||||
package containerd
|
package containerd
|
||||||
|
|
||||||
const Version = "0.0.5"
|
const Version = "0.1.0"
|
||||||
|
|
||||||
var GitCommit = ""
|
var GitCommit = ""
|
||||||
|
|
Loading…
Reference in a new issue