diff options
author | OpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com> | 2020-08-19 12:05:12 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-08-19 12:05:12 +0200 |
commit | 7e2a1b34c30e085275de1c484dc472682876746c (patch) | |
tree | 6d928baafba52d92475a8afebf07d38de39eb8ce /cmd/podman/system | |
parent | 9d096c1c4ea5308c94f779444b61015eeef2972a (diff) | |
parent | 5b02b69ea81deb06d5dc0acf2005cb3dbb496d4a (diff) | |
download | podman-7e2a1b34c30e085275de1c484dc472682876746c.tar.gz podman-7e2a1b34c30e085275de1c484dc472682876746c.tar.bz2 podman-7e2a1b34c30e085275de1c484dc472682876746c.zip |
Merge pull request #7311 from QiWang19/service-reload
Support sighup reload configuration files
Diffstat (limited to 'cmd/podman/system')
-rw-r--r-- | cmd/podman/system/service_abi.go | 26 |
1 files changed, 26 insertions, 0 deletions
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") +} |