func (c *Handler) LoadProxies(proxies []proxy.ApiProxySpec) { logutils.PrintH1("Installing API proxies:") for _, p := range proxies { logutils.PrintLi(" %s: installed", p.GetId()) c.AddProxy(p) } }
func NewWithConfig(httpAddr string, backend config.Backend) *Engine { ngnConfigurable := New(httpAddr) go func() { errC := config.NotifyOnChange(backend, ngnConfigurable) for err := range errC { logutils.PrintH1("[ERROR] Lost connectivity with etcd. Envoy will not accept further changes on the config file until this problem is resolved: %s", err.Error()) } }() return ngnConfigurable }
// Run is a convenience function that runs Engine as an HTTP // server. func (e *Engine) rawStart(ssl bool, certFile string, keyFile string) error { go func() { logutils.PrintH1("Server ready and listening on port%s", e.HttpServer.Addr) if ssl { e.errorC <- e.HttpServer.ListenAndServeTLS(certFile, keyFile) } else { e.errorC <- e.HttpServer.ListenAndServe() } }() //Block until either a signal or an error is received // based on service.go of vulcand project signal.Notify(e.sigC, syscall.SIGTERM, syscall.SIGINT, os.Kill, syscall.SIGUSR2, syscall.SIGCHLD) for { select { case signal := <-e.sigC: switch signal { case syscall.SIGTERM, syscall.SIGINT: fmt.Printf("\n") logutils.PrintH2("Received signal: %s!, shutting down gracefully...", signal) // put me a supevisor here logutils.PrintH1("Server stopped") //cleanupDone <- true return nil case syscall.SIGUSR1: return nil //default: // fmt.Printf("Ignoring signal: `%s`", signal) } case err := <-e.errorC: logutils.PrintH1("Internal HttpServer Error: %s", err) } } }