multi: cleanup proxy

This commit adds to ability to cleanup the Proxy by adding a Close
method and calling this method during server shut down.
This commit is contained in:
Elle Mouton
2021-05-21 15:20:51 +02:00
parent 7fdda6a504
commit 853b131d80
2 changed files with 10 additions and 2 deletions

View File

@@ -276,7 +276,7 @@ func (a *Aperture) Stop() error {
// Shut down our client and server connections now. This should cause
// the first goroutine to quit.
cleanup(a.etcdClient, a.httpsServer)
cleanup(a.etcdClient, a.httpsServer, a.proxy)
// If we started a tor server as well, shut it down now too to cause the
// second goroutine to quit.
@@ -514,7 +514,10 @@ func createProxy(cfg *Config, challenger *LndChallenger,
}
// cleanup closes the given server and shuts down the log rotator.
func cleanup(etcdClient io.Closer, server io.Closer) {
func cleanup(etcdClient io.Closer, server io.Closer, proxy io.Closer) {
if err := proxy.Close(); err != nil {
log.Errorf("Error terminating proxy: %v", err)
}
if err := etcdClient.Close(); err != nil {
log.Errorf("Error terminating etcd client: %v", err)
}

View File

@@ -186,6 +186,11 @@ func (p *Proxy) UpdateServices(services []*Service) error {
return nil
}
// Close cleans up the Proxy by closing any remaining open connections.
func (p *Proxy) Close() error {
return nil
}
// director is a method that rewrites an incoming request to be forwarded to a
// backend service.
func (p *Proxy) director(req *http.Request) {