Merge pull request #3275 from fuweid/me-redirect-shim-v1-output-into-fifo

containerd-shim: redirect output into stdout fifo
This commit is contained in:
Phil Estes 2019-05-13 16:16:30 +02:00 committed by GitHub
commit 7ad8848663
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -110,6 +110,10 @@ func main() {
stderr.Close() stderr.Close()
}() }()
// redirect the following output into fifo to make sure that containerd
// still can read the log after restart
logrus.SetOutput(stdout)
if err := executeShim(); err != nil { if err := executeShim(); err != nil {
fmt.Fprintf(os.Stderr, "containerd-shim: %s\n", err) fmt.Fprintf(os.Stderr, "containerd-shim: %s\n", err)
os.Exit(1) os.Exit(1)
@ -119,7 +123,7 @@ func main() {
// If containerd server process dies, we need the shim to keep stdout/err reader // If containerd server process dies, we need the shim to keep stdout/err reader
// FDs so that Linux does not SIGPIPE the shim process if it tries to use its end of // FDs so that Linux does not SIGPIPE the shim process if it tries to use its end of
// these pipes. // these pipes.
func openStdioKeepAlivePipes(dir string) (io.ReadCloser, io.ReadCloser, error) { func openStdioKeepAlivePipes(dir string) (io.ReadWriteCloser, io.ReadWriteCloser, error) {
background := context.Background() background := context.Background()
keepStdoutAlive, err := shimlog.OpenShimStdoutLog(background, dir) keepStdoutAlive, err := shimlog.OpenShimStdoutLog(background, dir)
if err != nil { if err != nil {