更新代码
This commit is contained in:
parent
0749c2eb4d
commit
9d383a5b5b
@ -172,6 +172,7 @@ func (ctl *Control) Close() error {
|
|||||||
ctl.mu.Lock()
|
ctl.mu.Lock()
|
||||||
defer ctl.mu.Unlock()
|
defer ctl.mu.Unlock()
|
||||||
ctl.exit = true
|
ctl.exit = true
|
||||||
|
ctl.conn.Close()
|
||||||
ctl.pm.CloseProxies()
|
ctl.pm.CloseProxies()
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
@ -52,9 +52,11 @@ func (svr *Service) Run(cmd bool) error {
|
|||||||
|
|
||||||
if cmd {
|
if cmd {
|
||||||
<-svr.closedCh
|
<-svr.closedCh
|
||||||
|
log.Info("svr closed")
|
||||||
} else {
|
} else {
|
||||||
go func() {
|
go func() {
|
||||||
<-svr.closedCh
|
<-svr.closedCh
|
||||||
|
log.Info("svr closed")
|
||||||
}()
|
}()
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
@ -62,4 +64,5 @@ func (svr *Service) Run(cmd bool) error {
|
|||||||
|
|
||||||
func (svr *Service) Close() {
|
func (svr *Service) Close() {
|
||||||
svr.ctl.Close()
|
svr.ctl.Close()
|
||||||
|
svr.closedCh <- 0
|
||||||
}
|
}
|
||||||
|
@ -112,6 +112,16 @@ func RunFrpc(cfgFilePath string) (err error) {
|
|||||||
return runClient(cfgFilePath)
|
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) {
|
func handleSignal(svr *client.Service) {
|
||||||
ch := make(chan os.Signal)
|
ch := make(chan os.Signal)
|
||||||
signal.Notify(ch, syscall.SIGINT, syscall.SIGTERM)
|
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)
|
err = svr.Run(cmd)
|
||||||
return
|
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