53 lines
912 B
Go
53 lines
912 B
Go
package main
|
|
|
|
import (
|
|
"fmt"
|
|
"os"
|
|
|
|
_ "github.com/gogf/gf/contrib/nosql/redis/v2"
|
|
"github.com/gogf/gf/v2/os/gproc"
|
|
|
|
_ "blazing/contrib/drivers/pgsql"
|
|
"blazing/logic/service/fight"
|
|
|
|
"blazing/cool"
|
|
|
|
//"blazing/o/service"
|
|
"net/http"
|
|
_ "net/http/pprof"
|
|
|
|
"github.com/gogf/gf/v2/os/gctx"
|
|
)
|
|
|
|
func PprofWeb() {
|
|
err := http.ListenAndServe(":9909", nil)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
}
|
|
func signalHandlerForMain(sig os.Signal) {
|
|
fight.Fightpool.Release()
|
|
fmt.Println("MainProcess is shutting down due to signal:", sig.String())
|
|
}
|
|
|
|
func main() {
|
|
|
|
if cool.IsRedisMode {
|
|
go cool.ListenFunc(gctx.New())
|
|
}
|
|
|
|
go Start(cool.Config.PortBL) //注入service
|
|
if cool.Config.PortBL == 1 { //只分析1服务器的
|
|
go PprofWeb()
|
|
}
|
|
|
|
fmt.Println("Process start, pid:", os.Getpid())
|
|
|
|
gproc.AddSigHandlerShutdown(
|
|
|
|
signalHandlerForMain,
|
|
)
|
|
|
|
gproc.Listen()
|
|
}
|