10383: Merge branch 'master' into 10383-arv-put-incremental-upload
[arvados.git] / services / arv-git-httpd / main.go
index ce18b713d72cc7feda757d257e1d8a408377b4a9..75645ff47215c2b5f7f666057006ea2510f99811 100644 (file)
@@ -9,32 +9,30 @@ import (
 
        "git.curoverse.com/arvados.git/sdk/go/arvados"
        "git.curoverse.com/arvados.git/sdk/go/config"
+       "github.com/coreos/go-systemd/daemon"
 )
 
 // Server configuration
 type Config struct {
-       Client     arvados.Client
-       Listen     string
-       GitCommand string
-       RepoRoot   string
+       Client       arvados.Client
+       Listen       string
+       GitCommand   string
+       RepoRoot     string
+       GitoliteHome string
 }
 
 var theConfig = defaultConfig()
 
 func defaultConfig() *Config {
-       cwd, err := os.Getwd()
-       if err != nil {
-               log.Fatalln("Getwd():", err)
-       }
        return &Config{
                Listen:     ":80",
                GitCommand: "/usr/bin/git",
-               RepoRoot:   cwd,
+               RepoRoot:   "/var/lib/arvados/git/repositories",
        }
 }
 
-func init() {
-       const defaultCfgPath = "/etc/arvados/arv-git-httpd/config.json"
+func main() {
+       const defaultCfgPath = "/etc/arvados/git-httpd/git-httpd.yml"
        const deprecated = " (DEPRECATED -- use config file instead)"
        flag.StringVar(&theConfig.Listen, "address", theConfig.Listen,
                "Address to listen on, \"host:port\" or \":port\"."+deprecated)
@@ -42,6 +40,8 @@ func init() {
                "Path to git or gitolite-shell executable. Each authenticated request will execute this program with a single argument, \"http-backend\"."+deprecated)
        flag.StringVar(&theConfig.RepoRoot, "repo-root", theConfig.RepoRoot,
                "Path to git repositories."+deprecated)
+       flag.StringVar(&theConfig.GitoliteHome, "gitolite-home", theConfig.GitoliteHome,
+               "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`.")
        flag.Usage = usage
@@ -63,20 +63,13 @@ func init() {
                }
        }
 
-       // MakeArvadosClient returns an error if token is unset (even
-       // though we don't need to do anything requiring
-       // authentication yet). We can't do this in newArvadosClient()
-       // just before calling MakeArvadosClient(), though, because
-       // that interferes with the env var needed by "run test
-       // servers".
-       os.Setenv("ARVADOS_API_TOKEN", "xxx")
-}
-
-func main() {
        srv := &server{}
        if err := srv.Start(); err != nil {
                log.Fatal(err)
        }
+       if _, err := daemon.SdNotify(false, "READY=1"); err != nil {
+               log.Printf("Error notifying init daemon: %v", err)
+       }
        log.Println("Listening at", srv.Addr)
        log.Println("Repository root", theConfig.RepoRoot)
        if err := srv.Wait(); err != nil {