- // Tell the built-in HTTP server to direct all requests to the REST
- // router.
- http.Handle("/", MakeRESTRouter(!no_get, !no_put, !no_head, kc))
+ listener, err = net.Listen("tcp", listen)
+ if err != nil {
+ log.Fatalf("Could not listen on %v", listen)
+ }
+
+ go RefreshServicesList(&kc)
+
+ // Shut down the server gracefully (by closing the listener)
+ // if SIGTERM is received.
+ term := make(chan os.Signal, 1)
+ go func(sig <-chan os.Signal) {
+ s := <-sig
+ log.Println("caught signal:", s)
+ listener.Close()
+ }(term)
+ signal.Notify(term, syscall.SIGTERM)
+ signal.Notify(term, syscall.SIGINT)
+
+ if pidfile != "" {
+ f, err := os.Create(pidfile)
+ if err == nil {
+ fmt.Fprint(f, os.Getpid())
+ f.Close()
+ } else {
+ log.Printf("Error writing pid file (%s): %s", pidfile, err.Error())
+ }
+ }
+
+ log.Printf("Arvados Keep proxy started listening on %v with server list %v", listener.Addr(), kc.ServiceRoots())