Commit 2b4fe412 authored by hujiebin's avatar hujiebin

fix:httpListen会阻塞

parent 390fb167
...@@ -29,11 +29,13 @@ func consulCheck(w http.ResponseWriter, r *http.Request) { ...@@ -29,11 +29,13 @@ func consulCheck(w http.ResponseWriter, r *http.Request) {
func register(port int, retry bool) { func register(port int, retry bool) {
checkPort := port + 1000 checkPort := port + 1000
if !retry { if !retry {
http.HandleFunc("/check", consulCheck) go func() {
if err := http.ListenAndServe(fmt.Sprintf(":%d", checkPort), nil); err != nil { http.HandleFunc("/check", consulCheck)
mylogrus.MyLog.Warnf("check server error :%v ", err) if err := http.ListenAndServe(fmt.Sprintf(":%d", checkPort), nil); err != nil {
return mylogrus.MyLog.Warnf("check server error :%v ", err)
} return
}
}()
} }
client, err := api.NewClient(api.DefaultConfig()) //非默认情况下需要设置实际的参数 client, err := api.NewClient(api.DefaultConfig()) //非默认情况下需要设置实际的参数
if err != nil { if err != nil {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment