1 // Copyright (C) The Arvados Authors. All rights reserved.
3 // SPDX-License-Identifier: AGPL-3.0
12 "git.arvados.org/arvados.git/lib/config"
13 "github.com/coreos/go-systemd/daemon"
14 "github.com/ghodss/yaml"
15 log "github.com/sirupsen/logrus"
22 log.SetFormatter(&log.JSONFormatter{
23 TimestampFormat: "2006-01-02T15:04:05.000000000Z07:00",
26 flags := flag.NewFlagSet(os.Args[0], flag.ExitOnError)
27 loader := config.NewLoader(os.Stdin, logger)
28 loader.SetupFlags(flags)
30 dumpConfig := flags.Bool("dump-config", false, "write current configuration to stdout and exit (useful for migrating from command line flags to config file)")
31 getVersion := flags.Bool("version", false, "print version information and exit.")
33 args := loader.MungeLegacyConfigArgs(logger, os.Args[1:], "-legacy-git-httpd-config")
37 fmt.Printf("arv-git-httpd %s\n", version)
41 cfg, err := loader.Load()
46 cluster, err := cfg.GetCluster("")
52 out, err := yaml.Marshal(cfg)
56 _, err = os.Stdout.Write(out)
63 srv := &server{cluster: cluster}
64 if err := srv.Start(); err != nil {
67 if _, err := daemon.SdNotify(false, "READY=1"); err != nil {
68 log.Printf("Error notifying init daemon: %v", err)
70 log.Printf("arv-git-httpd %s started", version)
71 log.Println("Listening at", srv.Addr)
72 log.Println("Repository root", cluster.Git.Repositories)
73 if err := srv.Wait(); err != nil {