Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-pages.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNick Thomas <nick@bytemark.co.uk>2016-05-05 15:16:32 +0300
committerNick Thomas <me@ur.gs>2016-09-09 01:56:37 +0300
commit33fca0976f95eac7ddce424080db9e381ec7388e (patch)
treeb0879a1eba1b3be67ec867d1b8a3027b5f0e2168 /daemon.go
parent62b22d776ebf3115e0ed2ae46191f40ae71fc0a7 (diff)
Allow -listen-http, -listen-https and -listen-proxy to be given more than once
Per issue #13, sometimes you want to listen on more than one port for each type of listener. This commit adds support for that.
Diffstat (limited to 'daemon.go')
-rw-r--r--daemon.go25
1 files changed, 15 insertions, 10 deletions
diff --git a/daemon.go b/daemon.go
index de6ce4a3..69feed1c 100644
--- a/daemon.go
+++ b/daemon.go
@@ -56,15 +56,20 @@ func daemonReexec(uid, gid uint, args ...string) (cmd *exec.Cmd, err error) {
return
}
-func daemonUpdateFd(cmd *exec.Cmd, fd *uintptr) {
- if *fd == 0 {
- return
- }
+func daemonUpdateFd(cmd *exec.Cmd, fd uintptr) (childFd uintptr) {
+ file := os.NewFile(fd, "[socket]")
- file := os.NewFile(*fd, "[socket]")
// we add 3 since, we have a 3 predefined FDs
- *fd = uintptr(3 + len(cmd.ExtraFiles))
+ childFd = uintptr(3 + len(cmd.ExtraFiles))
cmd.ExtraFiles = append(cmd.ExtraFiles, file)
+
+ return
+}
+
+func daemonUpdateFds(cmd *exec.Cmd, fds []uintptr) {
+ for idx, fd := range fds {
+ fds[idx] = daemonUpdateFd(cmd, fd)
+ }
}
func killProcess(cmd *exec.Cmd) {
@@ -196,10 +201,10 @@ func daemonize(config appConfig, uid, gid uint) {
defer configWriter.Close()
cmd.ExtraFiles = append(cmd.ExtraFiles, configReader)
- // Create a new file and store the FD
- daemonUpdateFd(cmd, &config.ListenHTTP)
- daemonUpdateFd(cmd, &config.ListenHTTPS)
- daemonUpdateFd(cmd, &config.ListenProxy)
+ // Create a new file and store the FD for each listener
+ daemonUpdateFds(cmd, config.ListenHTTP)
+ daemonUpdateFds(cmd, config.ListenHTTPS)
+ daemonUpdateFds(cmd, config.ListenProxy)
// Start the process
if err = cmd.Start(); err != nil {