mirror of
https://github.com/openimsdk/open-im-server.git
synced 2025-05-31 11:51:28 +08:00
add ppoff
This commit is contained in:
parent
bba7f47767
commit
d8396c2b46
@ -5,11 +5,16 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"net"
|
"net"
|
||||||
|
"os"
|
||||||
|
"runtime"
|
||||||
"strconv"
|
"strconv"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"gopkg.in/yaml.v3"
|
"gopkg.in/yaml.v3"
|
||||||
|
|
||||||
|
"net/http"
|
||||||
|
_ "net/http/pprof"
|
||||||
|
|
||||||
"github.com/OpenIMSDK/Open-IM-Server/internal/api"
|
"github.com/OpenIMSDK/Open-IM-Server/internal/api"
|
||||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/cmd"
|
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/cmd"
|
||||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/config"
|
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/config"
|
||||||
@ -29,6 +34,16 @@ func main() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func startPprof() {
|
||||||
|
runtime.GOMAXPROCS(1)
|
||||||
|
runtime.SetMutexProfileFraction(1)
|
||||||
|
runtime.SetBlockProfileRate(1)
|
||||||
|
if err := http.ListenAndServe(":6060", nil); err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
os.Exit(0)
|
||||||
|
}
|
||||||
|
|
||||||
func run(port int) error {
|
func run(port int) error {
|
||||||
if port == 0 {
|
if port == 0 {
|
||||||
port = config.Config.Api.GinPort[0]
|
port = config.Config.Api.GinPort[0]
|
||||||
@ -66,6 +81,7 @@ func run(port int) error {
|
|||||||
}
|
}
|
||||||
fmt.Println("start api server, address: ", address, ", OpenIM version: ", config.Version)
|
fmt.Println("start api server, address: ", address, ", OpenIM version: ", config.Version)
|
||||||
log.ZInfo(context.Background(), "start server success", "address", address, "version", config.Version)
|
log.ZInfo(context.Background(), "start server success", "address", address, "version", config.Version)
|
||||||
|
go startPprof()
|
||||||
err = router.Run(address)
|
err = router.Run(address)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.ZError(context.Background(), "api run failed ", err, "address", address)
|
log.ZError(context.Background(), "api run failed ", err, "address", address)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user