|
@@ -4,8 +4,20 @@ import (
|
|
"context"
|
|
"context"
|
|
"crypto/md5"
|
|
"crypto/md5"
|
|
"encoding/hex"
|
|
"encoding/hex"
|
|
|
|
+ "git.nspix.com/golang/micro/broker"
|
|
|
|
+ "git.nspix.com/golang/micro/gateway"
|
|
|
|
+ "git.nspix.com/golang/micro/gateway/cli"
|
|
|
|
+ "git.nspix.com/golang/micro/gateway/http"
|
|
|
|
+ "git.nspix.com/golang/micro/gateway/rpc"
|
|
|
|
+ "git.nspix.com/golang/micro/helper/docker"
|
|
|
|
+ "git.nspix.com/golang/micro/helper/machineid"
|
|
|
|
+ "git.nspix.com/golang/micro/helper/net/ip"
|
|
"git.nspix.com/golang/micro/helper/random"
|
|
"git.nspix.com/golang/micro/helper/random"
|
|
|
|
+ "git.nspix.com/golang/micro/helper/unsafestr"
|
|
"git.nspix.com/golang/micro/helper/utils"
|
|
"git.nspix.com/golang/micro/helper/utils"
|
|
|
|
+ "git.nspix.com/golang/micro/log"
|
|
|
|
+ "git.nspix.com/golang/micro/registry"
|
|
|
|
+ "github.com/google/btree"
|
|
"io/ioutil"
|
|
"io/ioutil"
|
|
"math"
|
|
"math"
|
|
"math/rand"
|
|
"math/rand"
|
|
@@ -20,22 +32,6 @@ import (
|
|
"sync/atomic"
|
|
"sync/atomic"
|
|
"syscall"
|
|
"syscall"
|
|
"time"
|
|
"time"
|
|
-
|
|
|
|
- "git.nspix.com/golang/micro/broker"
|
|
|
|
- "git.nspix.com/golang/micro/gateway/cli"
|
|
|
|
- "git.nspix.com/golang/micro/helper/machineid"
|
|
|
|
- "git.nspix.com/golang/micro/stats/prometheusbackend"
|
|
|
|
- "github.com/google/btree"
|
|
|
|
- "github.com/prometheus/client_golang/prometheus/promhttp"
|
|
|
|
-
|
|
|
|
- "git.nspix.com/golang/micro/gateway"
|
|
|
|
- "git.nspix.com/golang/micro/gateway/http"
|
|
|
|
- "git.nspix.com/golang/micro/gateway/rpc"
|
|
|
|
- "git.nspix.com/golang/micro/helper/docker"
|
|
|
|
- "git.nspix.com/golang/micro/helper/net/ip"
|
|
|
|
- "git.nspix.com/golang/micro/helper/unsafestr"
|
|
|
|
- "git.nspix.com/golang/micro/log"
|
|
|
|
- "git.nspix.com/golang/micro/registry"
|
|
|
|
)
|
|
)
|
|
|
|
|
|
var (
|
|
var (
|
|
@@ -315,6 +311,7 @@ func (svr *Service) startHTTPServe() (err error) {
|
|
}
|
|
}
|
|
log.Infof("http server stopped")
|
|
log.Infof("http server stopped")
|
|
})
|
|
})
|
|
|
|
+
|
|
svr.httpSvr.Handle("GET", "/healthy", func(ctx *http.Context) (err error) {
|
|
svr.httpSvr.Handle("GET", "/healthy", func(ctx *http.Context) (err error) {
|
|
return ctx.Success(map[string]interface{}{
|
|
return ctx.Success(map[string]interface{}{
|
|
"id": svr.node.ID,
|
|
"id": svr.node.ID,
|
|
@@ -323,11 +320,6 @@ func (svr *Service) startHTTPServe() (err error) {
|
|
})
|
|
})
|
|
})
|
|
})
|
|
|
|
|
|
- if svr.opts.EnableStats {
|
|
|
|
- prometheusbackend.Init(svr.opts.shortName)
|
|
|
|
- svr.httpSvr.Handler("GET", "/metrics", promhttp.Handler())
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
if svr.opts.EnableHttpPProf {
|
|
if svr.opts.EnableHttpPProf {
|
|
svr.httpSvr.Handler("GET", "/debug/pprof/", hp.HandlerFunc(pprof.Index))
|
|
svr.httpSvr.Handler("GET", "/debug/pprof/", hp.HandlerFunc(pprof.Index))
|
|
svr.httpSvr.Handler("GET", "/debug/pprof/goroutine", hp.HandlerFunc(pprof.Index))
|
|
svr.httpSvr.Handler("GET", "/debug/pprof/goroutine", hp.HandlerFunc(pprof.Index))
|
|
@@ -339,9 +331,9 @@ func (svr *Service) startHTTPServe() (err error) {
|
|
svr.httpSvr.Handler("GET", "/debug/pprof/symbol", hp.HandlerFunc(pprof.Symbol))
|
|
svr.httpSvr.Handler("GET", "/debug/pprof/symbol", hp.HandlerFunc(pprof.Symbol))
|
|
svr.httpSvr.Handler("GET", "/debug/pprof/trace", hp.HandlerFunc(pprof.Trace))
|
|
svr.httpSvr.Handler("GET", "/debug/pprof/trace", hp.HandlerFunc(pprof.Trace))
|
|
}
|
|
}
|
|
- log.Infof("attach http listener success")
|
|
|
|
|
|
+ log.Infof("http server listen on %s", svr.listener.Addr())
|
|
} else {
|
|
} else {
|
|
- log.Warnf("attach http listener failed cause by %s", err.Error())
|
|
|
|
|
|
+ log.Warnf("http server listen error: %s", err.Error())
|
|
}
|
|
}
|
|
return
|
|
return
|
|
}
|
|
}
|
|
@@ -356,9 +348,9 @@ func (svr *Service) startRPCServe() (err error) {
|
|
}
|
|
}
|
|
log.Infof("rpc server stopped")
|
|
log.Infof("rpc server stopped")
|
|
})
|
|
})
|
|
- log.Infof("attach rpc listener success")
|
|
|
|
|
|
+ log.Infof("rpc server listen on %s", svr.listener.Addr())
|
|
} else {
|
|
} else {
|
|
- log.Warnf("attach rpc listener failed cause by %s", err.Error())
|
|
|
|
|
|
+ log.Warnf("rpc server listen error: %s", err.Error())
|
|
}
|
|
}
|
|
return
|
|
return
|
|
}
|
|
}
|
|
@@ -373,9 +365,9 @@ func (svr *Service) startCliServe() (err error) {
|
|
}
|
|
}
|
|
log.Infof("cli server stopped")
|
|
log.Infof("cli server stopped")
|
|
})
|
|
})
|
|
- log.Infof("attach cli listener success")
|
|
|
|
|
|
+ log.Infof("cli server listen on %s", svr.listener.Addr())
|
|
} else {
|
|
} else {
|
|
- log.Warnf("attach cli listener failed cause by %s", err.Error())
|
|
|
|
|
|
+ log.Warnf("cli server listen error: %s", err.Error())
|
|
}
|
|
}
|
|
return
|
|
return
|
|
}
|
|
}
|