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 {
26 cwd, err := os.Getwd()
28 log.Fatalln("Getwd():", err)
32 GitCommand: "/usr/bin/git",
38 const defaultCfgPath = "/etc/arvados/arv-git-httpd/config.json"
39 const deprecated = " (DEPRECATED -- use config file instead)"
40 flag.StringVar(&theConfig.Listen, "address", theConfig.Listen,
41 "Address to listen on, \"host:port\" or \":port\"."+deprecated)
42 flag.StringVar(&theConfig.GitCommand, "git-command", theConfig.GitCommand,
43 "Path to git or gitolite-shell executable. Each authenticated request will execute this program with a single argument, \"http-backend\"."+deprecated)
44 flag.StringVar(&theConfig.RepoRoot, "repo-root", theConfig.RepoRoot,
45 "Path to git repositories."+deprecated)
47 cfgPath := flag.String("config", defaultCfgPath, "Configuration file `path`.")
51 err := config.LoadFile(theConfig, *cfgPath)
53 h := os.Getenv("ARVADOS_API_HOST")
54 if h == "" || !os.IsNotExist(err) || *cfgPath != defaultCfgPath {
57 log.Print("DEPRECATED: No config file found, but ARVADOS_API_HOST environment variable is set. Please use a config file instead.")
58 theConfig.Client.APIHost = h
59 if regexp.MustCompile("^(?i:1|yes|true)$").MatchString(os.Getenv("ARVADOS_API_HOST_INSECURE")) {
60 theConfig.Client.Insecure = true
62 if j, err := json.MarshalIndent(theConfig, "", " "); err == nil {
63 log.Print("Current configuration:\n", string(j))
67 // MakeArvadosClient returns an error if token is unset (even
68 // though we don't need to do anything requiring
69 // authentication yet). We can't do this in newArvadosClient()
70 // just before calling MakeArvadosClient(), though, because
71 // that interferes with the env var needed by "run test
73 os.Setenv("ARVADOS_API_TOKEN", "xxx")
78 if err := srv.Start(); err != nil {
81 if _, err := daemon.SdNotify("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 {