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"
15 // Server configuration
23 var theConfig = defaultConfig()
25 func defaultConfig() *Config {
28 GitCommand: "/usr/bin/git",
29 RepoRoot: "/var/lib/arvados/git/repositories",
34 const defaultCfgPath = "/etc/arvados/git-httpd/git-httpd.yml"
35 const deprecated = " (DEPRECATED -- use config file instead)"
36 flag.StringVar(&theConfig.Listen, "address", theConfig.Listen,
37 "Address to listen on, \"host:port\" or \":port\"."+deprecated)
38 flag.StringVar(&theConfig.GitCommand, "git-command", theConfig.GitCommand,
39 "Path to git or gitolite-shell executable. Each authenticated request will execute this program with a single argument, \"http-backend\"."+deprecated)
40 flag.StringVar(&theConfig.RepoRoot, "repo-root", theConfig.RepoRoot,
41 "Path to git repositories."+deprecated)
43 cfgPath := flag.String("config", defaultCfgPath, "Configuration file `path`.")
47 err := config.LoadFile(theConfig, *cfgPath)
49 h := os.Getenv("ARVADOS_API_HOST")
50 if h == "" || !os.IsNotExist(err) || *cfgPath != defaultCfgPath {
53 log.Print("DEPRECATED: No config file found, but ARVADOS_API_HOST environment variable is set. Please use a config file instead.")
54 theConfig.Client.APIHost = h
55 if regexp.MustCompile("^(?i:1|yes|true)$").MatchString(os.Getenv("ARVADOS_API_HOST_INSECURE")) {
56 theConfig.Client.Insecure = true
58 if j, err := json.MarshalIndent(theConfig, "", " "); err == nil {
59 log.Print("Current configuration:\n", string(j))
66 if err := srv.Start(); err != nil {
69 if _, err := daemon.SdNotify("READY=1"); err != nil {
70 log.Printf("Error notifying init daemon: %v", err)
72 log.Println("Listening at", srv.Addr)
73 log.Println("Repository root", theConfig.RepoRoot)
74 if err := srv.Wait(); err != nil {