10 "git.curoverse.com/arvados.git/sdk/go/arvados"
11 "git.curoverse.com/arvados.git/sdk/go/config"
12 "github.com/coreos/go-systemd/daemon"
13 "github.com/ghodss/yaml"
16 // Server configuration
25 var theConfig = defaultConfig()
27 func defaultConfig() *Config {
30 GitCommand: "/usr/bin/git",
31 RepoRoot: "/var/lib/arvados/git/repositories",
36 const defaultCfgPath = "/etc/arvados/git-httpd/git-httpd.yml"
37 const deprecated = " (DEPRECATED -- use config file instead)"
38 flag.StringVar(&theConfig.Listen, "address", theConfig.Listen,
39 "Address to listen on, \"host:port\" or \":port\"."+deprecated)
40 flag.StringVar(&theConfig.GitCommand, "git-command", theConfig.GitCommand,
41 "Path to git or gitolite-shell executable. Each authenticated request will execute this program with a single argument, \"http-backend\"."+deprecated)
42 flag.StringVar(&theConfig.RepoRoot, "repo-root", theConfig.RepoRoot,
43 "Path to git repositories."+deprecated)
44 flag.StringVar(&theConfig.GitoliteHome, "gitolite-home", theConfig.GitoliteHome,
45 "Value for GITOLITE_HTTP_HOME environment variable. If not empty, GL_BYPASS_ACCESS_CHECKS=1 will also be set."+deprecated)
47 cfgPath := flag.String("config", defaultCfgPath, "Configuration file `path`.")
48 dumpConfig := flag.Bool("dump-config", false, "write current configuration to stdout and exit (useful for migrating from command line flags to config file)")
52 err := config.LoadFile(theConfig, *cfgPath)
54 h := os.Getenv("ARVADOS_API_HOST")
55 if h == "" || !os.IsNotExist(err) || *cfgPath != defaultCfgPath {
58 log.Print("DEPRECATED: No config file found, but ARVADOS_API_HOST environment variable is set. Please use a config file instead.")
59 theConfig.Client.APIHost = h
60 if regexp.MustCompile("^(?i:1|yes|true)$").MatchString(os.Getenv("ARVADOS_API_HOST_INSECURE")) {
61 theConfig.Client.Insecure = true
63 if j, err := json.MarshalIndent(theConfig, "", " "); err == nil {
64 log.Print("Current configuration:\n", string(j))
69 y, err := yaml.Marshal(theConfig)
78 if err := srv.Start(); err != nil {
81 if _, err := daemon.SdNotify(false, "READY=1"); err != nil {
82 log.Printf("Error notifying init daemon: %v", err)
84 log.Println("Listening at", srv.Addr)
85 log.Println("Repository root", theConfig.RepoRoot)
86 if err := srv.Wait(); err != nil {