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 /main.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 'main.go')
-rw-r--r--main.go28
1 files changed, 15 insertions, 13 deletions
diff --git a/main.go b/main.go
index ba7a25db..62d28e0e 100644
--- a/main.go
+++ b/main.go
@@ -3,7 +3,6 @@ package main
import (
"flag"
"log"
- "net"
"os"
"strings"
)
@@ -16,9 +15,12 @@ var REVISION = "HEAD"
func appMain() {
var showVersion = flag.Bool("version", false, "Show version")
- var listenHTTP = flag.String("listen-http", "", "The address to listen for HTTP requests")
- var listenHTTPS = flag.String("listen-https", "", "The address to listen for HTTPS requests")
- var listenProxy = flag.String("listen-proxy", "", "The address to listen for proxy requests")
+ var listenHTTP, listenHTTPS, listenProxy MultiStringFlag
+
+ flag.Var(&listenHTTP, "listen-http", "The address(es) to listen on for HTTP requests")
+ flag.Var(&listenHTTPS, "listen-https", "The address(es) to listen on for HTTPS requests")
+ flag.Var(&listenProxy, "listen-proxy", "The address(es) to listen on for proxy requests")
+
var pagesRootCert = flag.String("root-cert", "", "The default path to file certificate to serve static pages")
var pagesRootKey = flag.String("root-key", "", "The default path to file certificate to serve static pages")
var redirectHTTP = flag.Bool("redirect-http", true, "Serve the pages under HTTP")
@@ -53,22 +55,22 @@ func appMain() {
config.RootKey = readFile(*pagesRootKey)
}
- if *listenHTTP != "" {
- var l net.Listener
- l, config.ListenHTTP = createSocket(*listenHTTP)
+ for _, addr := range listenHTTP {
+ l, fd := createSocket(addr)
defer l.Close()
+ config.ListenHTTP = append(config.ListenHTTP, fd)
}
- if *listenHTTPS != "" {
- var l net.Listener
- l, config.ListenHTTPS = createSocket(*listenHTTPS)
+ for _, addr := range listenHTTPS {
+ l, fd := createSocket(addr)
defer l.Close()
+ config.ListenHTTPS = append(config.ListenHTTPS, fd)
}
- if *listenProxy != "" {
- var l net.Listener
- l, config.ListenProxy = createSocket(*listenProxy)
+ for _, addr := range listenProxy {
+ l, fd := createSocket(addr)
defer l.Close()
+ config.ListenProxy = append(config.ListenProxy, fd)
}
if *daemonUID != 0 || *daemonGID != 0 {