some improvements

This commit is contained in:
fatedier 2022-04-14 11:24:36 +08:00
parent 6481870d03
commit 21240ed962
3 changed files with 9 additions and 3 deletions

View File

@ -357,8 +357,13 @@ func (svr *Service) ReloadConf(pxyCfgs map[string]config.ProxyConf, visitorCfgs
svr.cfgMu.Unlock() svr.cfgMu.Unlock()
svr.ctlMu.RLock() svr.ctlMu.RLock()
defer svr.ctlMu.RUnlock() ctl := svr.ctl
return svr.ctl.ReloadConf(pxyCfgs, visitorCfgs) svr.ctlMu.RUnlock()
if ctl != nil {
return svr.ctl.ReloadConf(pxyCfgs, visitorCfgs)
}
return nil
} }
func (svr *Service) Close() { func (svr *Service) Close() {

View File

@ -115,6 +115,7 @@ var rootCmd = &cobra.Command{
return nil return nil
} }
wg.Add(1) wg.Add(1)
time.Sleep(time.Millisecond)
go func() { go func() {
defer wg.Done() defer wg.Done()
err := runClient(path) err := runClient(path)

View File

@ -89,7 +89,7 @@ func NewHTTPReverseProxy(option HTTPReverseProxyOptions, vhostRouter *Routers) *
BufferPool: newWrapPool(), BufferPool: newWrapPool(),
ErrorLog: log.New(newWrapLogger(), "", 0), ErrorLog: log.New(newWrapLogger(), "", 0),
ErrorHandler: func(rw http.ResponseWriter, req *http.Request, err error) { ErrorHandler: func(rw http.ResponseWriter, req *http.Request, err error) {
frpLog.Warn("do http proxy request error: %v", err) frpLog.Warn("do http proxy request [host: %s] error: %v", req.Host, err)
rw.WriteHeader(http.StatusNotFound) rw.WriteHeader(http.StatusNotFound)
rw.Write(getNotFoundPageContent()) rw.Write(getNotFoundPageContent())
}, },