}
return nil
}
+
+// Dump returns a YAML representation of cfg.
+func Dump(cfg interface{}) ([]byte, error) {
+ return yaml.Marshal(cfg)
+}
func DefaultConfig() Config {
return Config{
+ Client: arvados.Client{
+ APIHost: "localhost:443",
+ },
+ Postgres: pgConfig{
+ "dbname": "arvados_test",
+ "user": "arvados",
+ "password": "xyzzy",
+ "host": "localhost",
+ "connect_timeout": "30",
+ "sslmode": "disable",
+ },
ClientEventQueue: 64,
}
}
import (
"flag"
+ "fmt"
"log"
"net/http"
"time"
func main() {
configPath := flag.String("config", "/etc/arvados/ws/ws.yml", "`path` to config file")
+ dumpConfig := flag.Bool("dump-config", false, "show current configuration and exit")
cfg := DefaultConfig()
+ flag.Parse()
+
err := config.LoadFile(&cfg, *configPath)
if err != nil {
log.Fatal(err)
}
+ if *dumpConfig {
+ txt, err := config.Dump(&cfg)
+ if err != nil {
+ log.Fatal(err)
+ }
+ fmt.Print(string(txt))
+ return
+ }
+
srv := &http.Server{
Addr: cfg.Listen,
ReadTimeout: time.Minute,