"time"
"git.curoverse.com/arvados.git/sdk/go/config"
- "github.com/Sirupsen/logrus"
+ "github.com/coreos/go-systemd/daemon"
)
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()
+ cfg := defaultConfig()
flag.Parse()
err := config.LoadFile(&cfg, *configPath)
log.Fatal(err)
}
- lvl, err := logrus.ParseLevel(cfg.LogLevel)
- if err != nil {
- log.Fatal(err)
- }
- rootLogger.Level = lvl
- switch cfg.LogFormat {
- case "text":
- rootLogger.Formatter = &logrus.TextFormatter{
- FullTimestamp: true,
- TimestampFormat: time.RFC3339Nano,
- }
- case "json":
- rootLogger.Formatter = &logrus.JSONFormatter{
- TimestampFormat: time.RFC3339Nano,
- }
- default:
- log.WithField("LogFormat", cfg.LogFormat).Fatal("unknown log format")
- }
+ loggerConfig(cfg)
if *dumpConfig {
txt, err := config.Dump(&cfg)
return
}
+ log.Info("started")
eventSource := &pgEventSource{
DataSource: cfg.Postgres.ConnectionString(),
QueueSize: cfg.ServerEventQueue,
WriteTimeout: time.Minute,
MaxHeaderBytes: 1 << 20,
Handler: &router{
- Config: &cfg,
- eventSource: eventSource,
+ Config: &cfg,
+ eventSource: eventSource,
+ newPermChecker: func() permChecker { return newPermChecker(cfg.Client) },
},
}
+ // Bootstrap the eventSource by attaching a dummy subscriber
+ // and hanging up.
eventSource.NewSink().Stop()
+ if _, err := daemon.SdNotify(false, "READY=1"); err != nil {
+ log.WithError(err).Warn("error notifying init daemon")
+ }
+
log.WithField("Listen", srv.Addr).Info("listening")
log.Fatal(srv.ListenAndServe())
}