Merge pull request #2 from wtsi-hgi/feature/arv-view
[arvados.git] / services / arv-git-httpd / main.go
1 package main
2
3 import (
4         "flag"
5         "log"
6         "os"
7 )
8
9 type config struct {
10         Addr       string
11         GitCommand string
12         Root       string
13 }
14
15 var theConfig *config
16
17 func init() {
18         theConfig = &config{}
19         flag.StringVar(&theConfig.Addr, "address", "0.0.0.0:80",
20                 "Address to listen on, \"host:port\".")
21         flag.StringVar(&theConfig.GitCommand, "git-command", "/usr/bin/git",
22                 "Path to git or gitolite-shell executable. Each authenticated request will execute this program with a single argument, \"http-backend\".")
23         cwd, err := os.Getwd()
24         if err != nil {
25                 log.Fatalln("Getwd():", err)
26         }
27         flag.StringVar(&theConfig.Root, "repo-root", cwd,
28                 "Path to git repositories.")
29
30         // MakeArvadosClient returns an error if token is unset (even
31         // though we don't need to do anything requiring
32         // authentication yet). We can't do this in newArvadosClient()
33         // just before calling MakeArvadosClient(), though, because
34         // that interferes with the env var needed by "run test
35         // servers".
36         os.Setenv("ARVADOS_API_TOKEN", "xxx")
37 }
38
39 func main() {
40         flag.Parse()
41         srv := &server{}
42         if err := srv.Start(); err != nil {
43                 log.Fatal(err)
44         }
45         log.Println("Listening at", srv.Addr)
46         log.Println("Repository root", theConfig.Root)
47         if err := srv.Wait(); err != nil {
48                 log.Fatal(err)
49         }
50 }