mirror of
https://github.com/openziti/zrok.git
synced 2025-06-25 20:22:45 +02:00
parent
5f81992283
commit
9653980a30
@ -2,6 +2,7 @@ package agent
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/openziti/zrok/agent/agentGrpc"
|
"github.com/openziti/zrok/agent/agentGrpc"
|
||||||
|
"github.com/openziti/zrok/agent/proctree"
|
||||||
"github.com/openziti/zrok/environment/env_core"
|
"github.com/openziti/zrok/environment/env_core"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
"github.com/sirupsen/logrus"
|
"github.com/sirupsen/logrus"
|
||||||
@ -61,9 +62,19 @@ func (a *Agent) Run() error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (a *Agent) Shutdown() {
|
func (a *Agent) Shutdown() {
|
||||||
|
logrus.Infof("stopping")
|
||||||
|
|
||||||
if err := os.Remove(a.agentSocket); err != nil {
|
if err := os.Remove(a.agentSocket); err != nil {
|
||||||
logrus.Warnf("unable to remove agent socket: %v", err)
|
logrus.Warnf("unable to remove agent socket: %v", err)
|
||||||
}
|
}
|
||||||
|
for _, shr := range a.shares {
|
||||||
|
logrus.Infof("stopping share '%v'", shr.token)
|
||||||
|
a.outShares <- shr
|
||||||
|
}
|
||||||
|
for _, acc := range a.accesses {
|
||||||
|
logrus.Infof("stopping access '%v'", acc.token)
|
||||||
|
a.outAccesses <- acc
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *Agent) manager() {
|
func (a *Agent) manager() {
|
||||||
@ -77,8 +88,18 @@ func (a *Agent) manager() {
|
|||||||
a.shares[inShare.token] = inShare
|
a.shares[inShare.token] = inShare
|
||||||
|
|
||||||
case outShare := <-a.outShares:
|
case outShare := <-a.outShares:
|
||||||
logrus.Infof("removing share '%v'", outShare.token)
|
if outShare.token != "" {
|
||||||
delete(a.shares, outShare.token)
|
logrus.Infof("removing share '%v'", outShare.token)
|
||||||
|
if err := proctree.StopChild(outShare.process); err != nil {
|
||||||
|
logrus.Errorf("error stopping share '%v': %v", outShare.token, err)
|
||||||
|
}
|
||||||
|
if err := proctree.WaitChild(outShare.process); err != nil {
|
||||||
|
logrus.Errorf("error joining share '%v': %v", outShare.token, err)
|
||||||
|
}
|
||||||
|
delete(a.shares, outShare.token)
|
||||||
|
} else {
|
||||||
|
logrus.Debug("skipping unidentified (orphaned) share removal")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user