mirror of https://github.com/rocboss/paopao-ce
commit
6a171c6ffc
Binary file not shown.
@ -0,0 +1,61 @@
|
|||||||
|
// Copyright 2023 ROC. All rights reserved.
|
||||||
|
// Use of this source code is governed by a MIT style
|
||||||
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
package service
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"net/http"
|
||||||
|
|
||||||
|
"github.com/Masterminds/semver/v3"
|
||||||
|
"github.com/fatih/color"
|
||||||
|
"github.com/gin-gonic/gin"
|
||||||
|
"github.com/rocboss/paopao-ce/internal/conf"
|
||||||
|
)
|
||||||
|
|
||||||
|
var (
|
||||||
|
_ Service = (*pprofService)(nil)
|
||||||
|
)
|
||||||
|
|
||||||
|
type pprofService struct {
|
||||||
|
*baseHttpService
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *pprofService) Name() string {
|
||||||
|
return "PprofService"
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *pprofService) Version() *semver.Version {
|
||||||
|
return semver.MustParse("v0.1.0")
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *pprofService) OnInit() error {
|
||||||
|
s.registerRoute(s, func(*gin.Engine) {})
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *pprofService) String() string {
|
||||||
|
return fmt.Sprintf("listen on %s\n", color.GreenString("http://%s:%s", conf.PprofServerSetting.HttpIp, conf.PprofServerSetting.HttpPort))
|
||||||
|
}
|
||||||
|
|
||||||
|
func newPprofService() Service {
|
||||||
|
addr := conf.PprofServerSetting.HttpIp + ":" + conf.PprofServerSetting.HttpPort
|
||||||
|
// notice this step just to register pprof server to start. don't share server with pprof.
|
||||||
|
server := httpServers.from(addr, func() *httpServer {
|
||||||
|
engine := newWebEngine()
|
||||||
|
return &httpServer{
|
||||||
|
baseServer: newBaseServe(),
|
||||||
|
e: engine,
|
||||||
|
server: &http.Server{
|
||||||
|
Addr: addr,
|
||||||
|
Handler: http.DefaultServeMux,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
})
|
||||||
|
return &pprofService{
|
||||||
|
baseHttpService: &baseHttpService{
|
||||||
|
server: server,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,12 @@
|
|||||||
|
// Copyright 2023 ROC. All rights reserved.
|
||||||
|
// Use of this source code is governed by a MIT style
|
||||||
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
//go:build pprof
|
||||||
|
// +build pprof
|
||||||
|
|
||||||
|
package debug
|
||||||
|
|
||||||
|
import (
|
||||||
|
_ "net/http/pprof"
|
||||||
|
)
|
Loading…
Reference in new issue