diff options
-rw-r--r-- | 404.go | 2 | ||||
-rw-r--r-- | Makefile | 3 | ||||
-rw-r--r-- | domain_test.go | 6 | ||||
-rw-r--r-- | main.go | 14 |
4 files changed, 18 insertions, 7 deletions
@@ -1,8 +1,8 @@ package main import ( - "net/http" "fmt" + "net/http" ) const predefined404 = ` @@ -27,8 +27,7 @@ fmt: go fmt ./... | awk '{ print "Please run go fmt"; exit 1 }' vet: - go get golang.org/x/tools/cmd/vet - go vet + go tool vet *.go lint: go get github.com/golang/lint/golint diff --git a/domain_test.go b/domain_test.go index 56e032a4..f10009c3 100644 --- a/domain_test.go +++ b/domain_test.go @@ -2,12 +2,12 @@ package main import ( "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + "mime" "net/http" + "net/http/httptest" "net/url" "testing" - "net/http/httptest" - "github.com/stretchr/testify/require" - "mime" ) func TestGroupServeHTTP(t *testing.T) { @@ -15,6 +15,7 @@ var VERSION = "dev" 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") @@ -27,9 +28,12 @@ func appMain() { var daemonUID = flag.Uint("daemon-uid", 0, "Drop privileges to this user") var daemonGID = flag.Uint("daemon-gid", 0, "Drop privileges to this group") + flag.Parse() + + printVersion(*showVersion, VERSION) + log.Printf("GitLab Pages Daemon %s (%s)", VERSION, REVISION) log.Printf("URL: https://gitlab.com/gitlab-org/gitlab-pages\n") - flag.Parse() err := os.Chdir(*pagesRoot) if err != nil { @@ -75,6 +79,14 @@ func appMain() { runApp(config) } +func printVersion(showVersion bool, version string) { + if showVersion { + log.SetFlags(0) + log.Printf(version) + os.Exit(0) + } +} + func main() { log.SetOutput(os.Stderr) |