This commit is contained in:
azw 2023-08-13 11:59:12 +08:00
parent c6e4546c13
commit f18d01d8a5
5 changed files with 21 additions and 21 deletions

12
app.go
View File

@ -60,10 +60,10 @@ func (this *app) init(userApp UserApp) {
atomic.StoreInt64(&this.nowUnixNano, this.nowTime.UnixNano())
_timer = &Timer{}
_timer.init()
_SysLog = new(SysLog_)
_SysLog.Init()
_TgLog = new(TGLog_)
_TgLog.Init()
_sysLog = new(SysLog_)
_sysLog.init()
_tgLog = new(TGLog_)
_tgLog.init()
{
var tmpNodeId, tmpInstanceId int
flag.IntVar(&tmpNodeId, "n", 0, "node id")
@ -76,7 +76,7 @@ func (this *app) init(userApp UserApp) {
this.chGoLoopTimerExit = make(chan int)
this.chGoLoopWait = make(chan int64)
this.outputRuningLog()
SysLog().Info("node_id:%d instance_id:%d pid:%d",
GetSysLog().Info("node_id:%d instance_id:%d pid:%d",
this.nodeId,
this.instanceId,
os.Getpid())
@ -224,7 +224,7 @@ func (this *app) installTimer() {
GetTimer().SetInterval(1000 * 60,
func (ev int32, params *q5.Args) {
if ev == q5.TIMER_EXEC_EVENT {
SysLog().Info("max_run_delay:%d max_schedule_time:%d",
GetSysLog().Info("max_run_delay:%d max_schedule_time:%d",
_app.maxRunDelay,
_app.maxScheduleTime)
_app.maxRunDelay = 0

View File

@ -2,19 +2,19 @@ package f5
var _app *app
var _timer *Timer
var _SysLog *SysLog_
var _TgLog *TGLog_
var _sysLog *SysLog_
var _tgLog *TGLog_
func GetTimer() *Timer {
return _timer
}
func SysLog() *SysLog_ {
return _SysLog
func GetSysLog() *SysLog_ {
return _sysLog
}
func TgLog() *TGLog_ {
return _TgLog
func GteTgLog() *TGLog_ {
return _tgLog
}
func GetApp() App {

View File

@ -40,13 +40,13 @@ func (this *HttpServer) Init(serviceName string, logOutputTime int32) *HttpServe
func (c *Context) {
c.Response(`{"errcode":0, "errmsg":"", "healthy":1, "max_rundelay":10}`)
})
SysLog().Info("HttpServer.Init")
GetSysLog().Info("HttpServer.Init")
if logOutputTime > 0 {
GetTimer().SetInterval(
logOutputTime,
func (ev int32, params *q5.Args) {
if ev == q5.TIMER_EXEC_EVENT {
SysLog().Info("%s maxHandleTime:%d totalRequestTimes:%d okTimes:%d pageNotFoundTimes:%d",
GetSysLog().Info("%s maxHandleTime:%d totalRequestTimes:%d okTimes:%d pageNotFoundTimes:%d",
serviceName,
this.maxHandleTime,
this.totalRequestTimes,
@ -62,13 +62,13 @@ func (this *HttpServer) Init(serviceName string, logOutputTime int32) *HttpServe
}
func (this *HttpServer) UnInit() {
SysLog().Info("HttpServer.UnInit")
GetSysLog().Info("HttpServer.UnInit")
}
func (this *HttpServer) Start(listen_port int32) {
atomic.AddInt64(&this.totalRequestTimes, 1)
this.installGlobalMiddleware()
SysLog().Info("HttpServer.Start listen_port:%d", listen_port)
GetSysLog().Info("HttpServer.Start listen_port:%d", listen_port)
go http.ListenAndServe(fmt.Sprintf("0.0.0.0:%d", listen_port), nil)
}
@ -85,7 +85,7 @@ func (this *HttpServer) dispatchRequest(c *Context) {
}
atomic.AddInt64(&this.okTimes, 1)
if err := recover(); err != nil {
SysLog().Error("handle name:%s error:%s", handleName, err)
GetSysLog().Error("handle name:%s error:%s", handleName, err)
c.Response(`{"errcode":500, "errmsg":"server internal error"}`)
}
}()

View File

@ -34,12 +34,12 @@ type SysLog_ struct {
chGoSaveExit chan int
}
func (this *SysLog_) Init() {
func (this *SysLog_) init() {
this.chGoSaveExit = make(chan int)
go this.goSaveToFile()
}
func (this *SysLog_) UnInit() {
func (this *SysLog_) unInit() {
this.chGoSaveExit <- 1
}

View File

@ -24,12 +24,12 @@ type TGLog_ struct {
chGoSaveExit chan int
}
func (this *TGLog_) Init() {
func (this *TGLog_) init() {
this.chGoSaveExit = make(chan int)
//go this.goSaveToFile()
}
func (this *TGLog_) UnInit() {
func (this *TGLog_) unInit() {
this.chGoSaveExit <- 1
}