diff options
author | OpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com> | 2020-10-20 11:16:11 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-10-20 11:16:11 -0400 |
commit | 6c0b600e7d49d17db6eedd21b755b5d4f1a15b11 (patch) | |
tree | bacb719aef9c18e181d4014abb37d3a103f7a601 /libpod/runtime.go | |
parent | 35b4cb196545eee3b072083e716ad4588e0bb486 (diff) | |
parent | f58d2f5e75b4982774509847c18b39f4a50fd5be (diff) | |
download | podman-6c0b600e7d49d17db6eedd21b755b5d4f1a15b11.tar.gz podman-6c0b600e7d49d17db6eedd21b755b5d4f1a15b11.tar.bz2 podman-6c0b600e7d49d17db6eedd21b755b5d4f1a15b11.zip |
Merge pull request #7999 from mheon/signal_handler
Add a shutdown signal handler
Diffstat (limited to 'libpod/runtime.go')
-rw-r--r-- | libpod/runtime.go | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/libpod/runtime.go b/libpod/runtime.go index 7da8b181f..ccd920ab0 100644 --- a/libpod/runtime.go +++ b/libpod/runtime.go @@ -17,6 +17,7 @@ import ( "github.com/containers/podman/v2/libpod/events" "github.com/containers/podman/v2/libpod/image" "github.com/containers/podman/v2/libpod/lock" + "github.com/containers/podman/v2/libpod/shutdown" "github.com/containers/podman/v2/pkg/cgroups" "github.com/containers/podman/v2/pkg/registries" "github.com/containers/podman/v2/pkg/rootless" @@ -174,9 +175,21 @@ func newRuntimeFromConfig(ctx context.Context, conf *config.Config, options ...R } } + if err := shutdown.Start(); err != nil { + return nil, errors.Wrapf(err, "error starting shutdown signal handler") + } + if err := makeRuntime(ctx, runtime); err != nil { return nil, err } + + if err := shutdown.Register("libpod", func(sig os.Signal) error { + os.Exit(1) + return nil + }); err != nil { + logrus.Errorf("Error registering shutdown handler for libpod: %v", err) + } + return runtime, nil } |