diff options
Diffstat (limited to 'cmd/podman')
-rw-r--r-- | cmd/podman/registry/remote.go | 5 | ||||
-rw-r--r-- | cmd/podman/system/service_abi.go | 26 | ||||
-rw-r--r-- | cmd/podman/utils/signals_linux.go | 14 | ||||
-rw-r--r-- | cmd/podman/utils/signals_windows.go | 14 |
4 files changed, 57 insertions, 2 deletions
diff --git a/cmd/podman/registry/remote.go b/cmd/podman/registry/remote.go index 9b7523ac0..78b820269 100644 --- a/cmd/podman/registry/remote.go +++ b/cmd/podman/registry/remote.go @@ -15,13 +15,14 @@ var remoteFromCLI = struct { }{} // IsRemote returns true if podman was built to run remote or --remote flag given on CLI -// Use in init() functions as a initialization check +// Use in init() functions as an initialization check func IsRemote() bool { remoteFromCLI.sync.Do(func() { fs := pflag.NewFlagSet("remote", pflag.ContinueOnError) - fs.BoolVarP(&remoteFromCLI.Value, "remote", "r", false, "") fs.ParseErrorsWhitelist.UnknownFlags = true + fs.Usage = func() {} fs.SetInterspersed(false) + fs.BoolVarP(&remoteFromCLI.Value, "remote", "r", false, "") _ = fs.Parse(os.Args[1:]) }) return podmanOptions.EngineMode == entities.TunnelMode || remoteFromCLI.Value diff --git a/cmd/podman/system/service_abi.go b/cmd/podman/system/service_abi.go index 6c6dd42a4..95cbd19d9 100644 --- a/cmd/podman/system/service_abi.go +++ b/cmd/podman/system/service_abi.go @@ -5,8 +5,12 @@ package system import ( "context" "net" + "os" + "os/signal" "strings" + "github.com/containers/podman/v2/cmd/podman/utils" + "github.com/containers/podman/v2/libpod" api "github.com/containers/podman/v2/pkg/api/server" "github.com/containers/podman/v2/pkg/domain/entities" "github.com/containers/podman/v2/pkg/domain/infra" @@ -39,6 +43,7 @@ func restService(opts entities.ServiceOptions, flags *pflag.FlagSet, cfg *entiti return err } + startWatcher(rt) server, err := api.NewServerWithSettings(rt, opts.Timeout, listener) if err != nil { return err @@ -55,3 +60,24 @@ func restService(opts entities.ServiceOptions, flags *pflag.FlagSet, cfg *entiti } return err } + +// startWatcher starts a new SIGHUP go routine for the current config. +func startWatcher(rt *libpod.Runtime) { + // Setup the signal notifier + ch := make(chan os.Signal, 1) + signal.Notify(ch, utils.SIGHUP) + + go func() { + for { + // Block until the signal is received + logrus.Debugf("waiting for SIGHUP to reload configuration") + <-ch + if err := rt.Reload(); err != nil { + logrus.Errorf("unable to reload configuration: %v", err) + continue + } + } + }() + + logrus.Debugf("registered SIGHUP watcher for config") +} diff --git a/cmd/podman/utils/signals_linux.go b/cmd/podman/utils/signals_linux.go new file mode 100644 index 000000000..f0a14aff0 --- /dev/null +++ b/cmd/podman/utils/signals_linux.go @@ -0,0 +1,14 @@ +// +build !windows + +package utils + +import ( + "os" + + "golang.org/x/sys/unix" +) + +// Platform specific signal synonyms +var ( + SIGHUP os.Signal = unix.SIGHUP +) diff --git a/cmd/podman/utils/signals_windows.go b/cmd/podman/utils/signals_windows.go new file mode 100644 index 000000000..30b058cb9 --- /dev/null +++ b/cmd/podman/utils/signals_windows.go @@ -0,0 +1,14 @@ +// +build windows + +package utils + +import ( + "os" + + "golang.org/x/sys/windows" +) + +// Platform specific signal synonyms +var ( + SIGHUP os.Signal = windows.SIGHUP +) |