8460: Merge branch 'master' into 8460-websocket-go
[arvados.git] / services / ws / main.go
index 0031dc0062a8d4c8462906bbff37c8f22314463b..77ebf9ee4a8aed2e6b85454f0a3a77570df11bab 100644 (file)
@@ -7,6 +7,7 @@ import (
        "time"
 
        "git.curoverse.com/arvados.git/sdk/go/config"
+       "github.com/coreos/go-systemd/daemon"
 )
 
 func main() {
@@ -14,7 +15,7 @@ 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)
@@ -33,6 +34,7 @@ func main() {
                return
        }
 
+       log.Info("started")
        eventSource := &pgEventSource{
                DataSource: cfg.Postgres.ConnectionString(),
                QueueSize:  cfg.ServerEventQueue,
@@ -45,11 +47,17 @@ func main() {
                Handler: &router{
                        Config:         &cfg,
                        eventSource:    eventSource,
-                       newPermChecker: func() permChecker { return NewPermChecker(cfg.Client) },
+                       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())
 }