Commit 2b4fe412 authored by hujiebin's avatar hujiebin

fix:httpListen会阻塞

parent 390fb167
......@@ -29,11 +29,13 @@ func consulCheck(w http.ResponseWriter, r *http.Request) {
func register(port int, retry bool) {
checkPort := port + 1000
if !retry {
http.HandleFunc("/check", consulCheck)
if err := http.ListenAndServe(fmt.Sprintf(":%d", checkPort), nil); err != nil {
mylogrus.MyLog.Warnf("check server error :%v ", err)
return
}
go func() {
http.HandleFunc("/check", consulCheck)
if err := http.ListenAndServe(fmt.Sprintf(":%d", checkPort), nil); err != nil {
mylogrus.MyLog.Warnf("check server error :%v ", err)
return
}
}()
}
client, err := api.NewClient(api.DefaultConfig()) //非默认情况下需要设置实际的参数
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