Merge branch '12037-cwl-v1.0.1' closes #12037
[arvados.git] / services / arv-git-httpd / main.go
index 3bd7b3a8aa93c5871ff18773188c1336033d2599..79a3eb3f7b85de9667c04fe1b24f2a5217db5772 100644 (file)
@@ -1,3 +1,7 @@
+// Copyright (C) The Arvados Authors. All rights reserved.
+//
+// SPDX-License-Identifier: AGPL-3.0
+
 package main
 
 import (
@@ -14,11 +18,12 @@ import (
 
 // Server configuration
 type Config struct {
-       Client       arvados.Client
-       Listen       string
-       GitCommand   string
-       RepoRoot     string
-       GitoliteHome string
+       Client          arvados.Client
+       Listen          string
+       GitCommand      string
+       RepoRoot        string
+       GitoliteHome    string
+       ManagementToken string
 }
 
 var theConfig = defaultConfig()
@@ -44,6 +49,11 @@ func main() {
                "Value for GITOLITE_HTTP_HOME environment variable. If not empty, GL_BYPASS_ACCESS_CHECKS=1 will also be set."+deprecated)
 
        cfgPath := flag.String("config", defaultCfgPath, "Configuration file `path`.")
+       dumpConfig := flag.Bool("dump-config", false, "write current configuration to stdout and exit (useful for migrating from command line flags to config file)")
+
+       flag.StringVar(&theConfig.ManagementToken, "management-token", theConfig.ManagementToken,
+               "Authorization token to be included in all health check requests.")
+
        flag.Usage = usage
        flag.Parse()
 
@@ -63,11 +73,15 @@ func main() {
                }
        }
 
+       if *dumpConfig {
+               log.Fatal(config.DumpAndExit(theConfig))
+       }
+
        srv := &server{}
        if err := srv.Start(); err != nil {
                log.Fatal(err)
        }
-       if _, err := daemon.SdNotify("READY=1"); err != nil {
+       if _, err := daemon.SdNotify(false, "READY=1"); err != nil {
                log.Printf("Error notifying init daemon: %v", err)
        }
        log.Println("Listening at", srv.Addr)