mirror of
https://github.com/openziti/zrok.git
synced 2025-01-10 16:08:20 +01:00
stop the backend handler (#463)
This commit is contained in:
parent
e58524572f
commit
e7405cd9bb
@ -39,4 +39,5 @@ type agentGrpcImpl struct {
|
||||
|
||||
type backendHandler interface {
|
||||
Run() error
|
||||
Stop() error
|
||||
}
|
||||
|
@ -3,10 +3,20 @@ package agent
|
||||
import (
|
||||
"context"
|
||||
"github.com/openziti/zrok/agent/agentGrpc"
|
||||
"github.com/pkg/errors"
|
||||
"github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
func (i *agentGrpcImpl) ReleaseShare(_ context.Context, req *agentGrpc.ReleaseShareRequest) (*agentGrpc.ReleaseShareReply, error) {
|
||||
logrus.Infof("releasing '%v'", req.Token)
|
||||
if shr, found := i.a.shares[req.Token]; found {
|
||||
logrus.Infof("stopping share '%v'", shr.token)
|
||||
if err := shr.handler.Stop(); err != nil {
|
||||
logrus.Error(err)
|
||||
}
|
||||
delete(i.a.shares, shr.token)
|
||||
logrus.Infof("released share '%v'", shr.token)
|
||||
} else {
|
||||
return nil, errors.Errorf("agent has no share with token '%v'", req.Token)
|
||||
}
|
||||
return nil, nil
|
||||
}
|
||||
|
@ -67,6 +67,10 @@ func (b *Backend) Run() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (b *Backend) Stop() error {
|
||||
return b.listener.Close()
|
||||
}
|
||||
|
||||
func newReverseProxy(cfg *BackendConfig) (*httputil.ReverseProxy, error) {
|
||||
targetURL, err := url.Parse(cfg.EndpointAddress)
|
||||
if err != nil {
|
||||
|
Loading…
Reference in New Issue
Block a user