更新代码
This commit is contained in:
parent
0749c2eb4d
commit
9d383a5b5b
@ -172,6 +172,7 @@ func (ctl *Control) Close() error {
|
||||
ctl.mu.Lock()
|
||||
defer ctl.mu.Unlock()
|
||||
ctl.exit = true
|
||||
ctl.conn.Close()
|
||||
ctl.pm.CloseProxies()
|
||||
return nil
|
||||
}
|
||||
|
@ -52,9 +52,11 @@ func (svr *Service) Run(cmd bool) error {
|
||||
|
||||
if cmd {
|
||||
<-svr.closedCh
|
||||
log.Info("svr closed")
|
||||
} else {
|
||||
go func() {
|
||||
<-svr.closedCh
|
||||
log.Info("svr closed")
|
||||
}()
|
||||
}
|
||||
return nil
|
||||
@ -62,4 +64,5 @@ func (svr *Service) Run(cmd bool) error {
|
||||
|
||||
func (svr *Service) Close() {
|
||||
svr.ctl.Close()
|
||||
svr.closedCh <- 0
|
||||
}
|
||||
|
@ -112,6 +112,16 @@ func RunFrpc(cfgFilePath string) (err error) {
|
||||
return runClient(cfgFilePath)
|
||||
}
|
||||
|
||||
func StopFrp() (err error) {
|
||||
if service == nil {
|
||||
return fmt.Errorf("frp not start")
|
||||
}
|
||||
|
||||
service.Close()
|
||||
log.Info("frpc is stoped")
|
||||
return
|
||||
}
|
||||
|
||||
func handleSignal(svr *client.Service) {
|
||||
ch := make(chan os.Signal)
|
||||
signal.Notify(ch, syscall.SIGINT, syscall.SIGTERM)
|
||||
@ -225,13 +235,3 @@ func startService(pxyCfgs map[string]config.ProxyConf, visitorCfgs map[string]co
|
||||
err = svr.Run(cmd)
|
||||
return
|
||||
}
|
||||
|
||||
func StopFrp() (err error) {
|
||||
if service == nil {
|
||||
return fmt.Errorf("frp not start")
|
||||
}
|
||||
|
||||
service.Close()
|
||||
log.Info("frpc is stoped")
|
||||
return
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user