diff options
author | Balasankar "Balu" C <balasankarc@autistici.org> | 2021-02-17 10:56:11 +0300 |
---|---|---|
committer | Balasankar "Balu" C <balasankarc@autistici.org> | 2021-03-01 08:35:57 +0300 |
commit | b7e2085b76c11212ac41f80672d5c5f9b0287fee (patch) | |
tree | 92bb6e221257aeea9da8986c6f1e2a297b9c089c /daemon.go | |
parent | 01da18ea5717658eb98f539f921ed02fd35bd3d1 (diff) |
Move configuration parsing to Config package
Changelog: changed
Signed-off-by: Balasankar "Balu" C <balasankarc@autistici.org>
Diffstat (limited to 'daemon.go')
-rw-r--r-- | daemon.go | 20 |
1 files changed, 13 insertions, 7 deletions
@@ -15,6 +15,7 @@ import ( "github.com/kardianos/osext" log "github.com/sirupsen/logrus" + "gitlab.com/gitlab-org/gitlab-pages/internal/config" "gitlab.com/gitlab-org/gitlab-pages/internal/jail" ) @@ -43,7 +44,7 @@ func daemonMain() { }).Info("starting the daemon as unprivileged user") // read the configuration from the pipe "ExtraFiles" - var config appConfig + var config config.Config if err := json.NewDecoder(os.NewFile(3, "options")).Decode(&config); err != nil { fatal(err, "could not decode app config") } @@ -266,7 +267,12 @@ func jailDaemon(pagesRoot string, cmd *exec.Cmd) (*jail.Jail, error) { return cage, nil } -func daemonize(config appConfig, uid, gid uint, inPlace bool, pagesRoot string) error { +func daemonize(config config.Config) error { + uid := uint(config.Daemon.UID) + gid := uint(config.Daemon.GID) + inPlace := config.Daemon.InplaceChroot + pagesRoot := config.General.RootDir + // Ensure pagesRoot is an absolute path. This will produce a different path // if any component of pagesRoot is a symlink (not likely). For example, // -pages-root=/some-path where ln -s /other-path /some-path @@ -344,12 +350,12 @@ func daemonize(config appConfig, uid, gid uint, inPlace bool, pagesRoot string) return cmd.Wait() } -func updateFds(config *appConfig, cmd *exec.Cmd) { +func updateFds(config *config.Config, cmd *exec.Cmd) { for _, fds := range [][]uintptr{ - config.ListenHTTP, - config.ListenHTTPS, - config.ListenProxy, - config.ListenHTTPSProxyv2, + config.Listeners.HTTP, + config.Listeners.HTTPS, + config.Listeners.Proxy, + config.Listeners.HTTPSProxyv2, } { daemonUpdateFds(cmd, fds) } |