1
This commit is contained in:
parent
c6e4546c13
commit
f18d01d8a5
12
app.go
12
app.go
@ -60,10 +60,10 @@ func (this *app) init(userApp UserApp) {
|
|||||||
atomic.StoreInt64(&this.nowUnixNano, this.nowTime.UnixNano())
|
atomic.StoreInt64(&this.nowUnixNano, this.nowTime.UnixNano())
|
||||||
_timer = &Timer{}
|
_timer = &Timer{}
|
||||||
_timer.init()
|
_timer.init()
|
||||||
_SysLog = new(SysLog_)
|
_sysLog = new(SysLog_)
|
||||||
_SysLog.Init()
|
_sysLog.init()
|
||||||
_TgLog = new(TGLog_)
|
_tgLog = new(TGLog_)
|
||||||
_TgLog.Init()
|
_tgLog.init()
|
||||||
{
|
{
|
||||||
var tmpNodeId, tmpInstanceId int
|
var tmpNodeId, tmpInstanceId int
|
||||||
flag.IntVar(&tmpNodeId, "n", 0, "node id")
|
flag.IntVar(&tmpNodeId, "n", 0, "node id")
|
||||||
@ -76,7 +76,7 @@ func (this *app) init(userApp UserApp) {
|
|||||||
this.chGoLoopTimerExit = make(chan int)
|
this.chGoLoopTimerExit = make(chan int)
|
||||||
this.chGoLoopWait = make(chan int64)
|
this.chGoLoopWait = make(chan int64)
|
||||||
this.outputRuningLog()
|
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.nodeId,
|
||||||
this.instanceId,
|
this.instanceId,
|
||||||
os.Getpid())
|
os.Getpid())
|
||||||
@ -224,7 +224,7 @@ func (this *app) installTimer() {
|
|||||||
GetTimer().SetInterval(1000 * 60,
|
GetTimer().SetInterval(1000 * 60,
|
||||||
func (ev int32, params *q5.Args) {
|
func (ev int32, params *q5.Args) {
|
||||||
if ev == q5.TIMER_EXEC_EVENT {
|
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.maxRunDelay,
|
||||||
_app.maxScheduleTime)
|
_app.maxScheduleTime)
|
||||||
_app.maxRunDelay = 0
|
_app.maxRunDelay = 0
|
||||||
|
12
export.go
12
export.go
@ -2,19 +2,19 @@ package f5
|
|||||||
|
|
||||||
var _app *app
|
var _app *app
|
||||||
var _timer *Timer
|
var _timer *Timer
|
||||||
var _SysLog *SysLog_
|
var _sysLog *SysLog_
|
||||||
var _TgLog *TGLog_
|
var _tgLog *TGLog_
|
||||||
|
|
||||||
func GetTimer() *Timer {
|
func GetTimer() *Timer {
|
||||||
return _timer
|
return _timer
|
||||||
}
|
}
|
||||||
|
|
||||||
func SysLog() *SysLog_ {
|
func GetSysLog() *SysLog_ {
|
||||||
return _SysLog
|
return _sysLog
|
||||||
}
|
}
|
||||||
|
|
||||||
func TgLog() *TGLog_ {
|
func GteTgLog() *TGLog_ {
|
||||||
return _TgLog
|
return _tgLog
|
||||||
}
|
}
|
||||||
|
|
||||||
func GetApp() App {
|
func GetApp() App {
|
||||||
|
@ -40,13 +40,13 @@ func (this *HttpServer) Init(serviceName string, logOutputTime int32) *HttpServe
|
|||||||
func (c *Context) {
|
func (c *Context) {
|
||||||
c.Response(`{"errcode":0, "errmsg":"", "healthy":1, "max_rundelay":10}`)
|
c.Response(`{"errcode":0, "errmsg":"", "healthy":1, "max_rundelay":10}`)
|
||||||
})
|
})
|
||||||
SysLog().Info("HttpServer.Init")
|
GetSysLog().Info("HttpServer.Init")
|
||||||
if logOutputTime > 0 {
|
if logOutputTime > 0 {
|
||||||
GetTimer().SetInterval(
|
GetTimer().SetInterval(
|
||||||
logOutputTime,
|
logOutputTime,
|
||||||
func (ev int32, params *q5.Args) {
|
func (ev int32, params *q5.Args) {
|
||||||
if ev == q5.TIMER_EXEC_EVENT {
|
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,
|
serviceName,
|
||||||
this.maxHandleTime,
|
this.maxHandleTime,
|
||||||
this.totalRequestTimes,
|
this.totalRequestTimes,
|
||||||
@ -62,13 +62,13 @@ func (this *HttpServer) Init(serviceName string, logOutputTime int32) *HttpServe
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (this *HttpServer) UnInit() {
|
func (this *HttpServer) UnInit() {
|
||||||
SysLog().Info("HttpServer.UnInit")
|
GetSysLog().Info("HttpServer.UnInit")
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *HttpServer) Start(listen_port int32) {
|
func (this *HttpServer) Start(listen_port int32) {
|
||||||
atomic.AddInt64(&this.totalRequestTimes, 1)
|
atomic.AddInt64(&this.totalRequestTimes, 1)
|
||||||
this.installGlobalMiddleware()
|
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)
|
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)
|
atomic.AddInt64(&this.okTimes, 1)
|
||||||
if err := recover(); err != nil {
|
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"}`)
|
c.Response(`{"errcode":500, "errmsg":"server internal error"}`)
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
@ -34,12 +34,12 @@ type SysLog_ struct {
|
|||||||
chGoSaveExit chan int
|
chGoSaveExit chan int
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *SysLog_) Init() {
|
func (this *SysLog_) init() {
|
||||||
this.chGoSaveExit = make(chan int)
|
this.chGoSaveExit = make(chan int)
|
||||||
go this.goSaveToFile()
|
go this.goSaveToFile()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *SysLog_) UnInit() {
|
func (this *SysLog_) unInit() {
|
||||||
this.chGoSaveExit <- 1
|
this.chGoSaveExit <- 1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
4
tglog.go
4
tglog.go
@ -24,12 +24,12 @@ type TGLog_ struct {
|
|||||||
chGoSaveExit chan int
|
chGoSaveExit chan int
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *TGLog_) Init() {
|
func (this *TGLog_) init() {
|
||||||
this.chGoSaveExit = make(chan int)
|
this.chGoSaveExit = make(chan int)
|
||||||
//go this.goSaveToFile()
|
//go this.goSaveToFile()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *TGLog_) UnInit() {
|
func (this *TGLog_) unInit() {
|
||||||
this.chGoSaveExit <- 1
|
this.chGoSaveExit <- 1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user