1
This commit is contained in:
parent
206070d18e
commit
b46f1d1902
@ -1,35 +1,34 @@
|
||||
package main
|
||||
package app
|
||||
|
||||
import (
|
||||
"f5"
|
||||
"main/db"
|
||||
"mt"
|
||||
"main/constant"
|
||||
)
|
||||
|
||||
type App struct {
|
||||
type app struct {
|
||||
}
|
||||
|
||||
func (this *App) GetPkgName() string {
|
||||
func (this *app) GetPkgName() string {
|
||||
return "adminserver"
|
||||
}
|
||||
|
||||
func (this *App) Init() {
|
||||
func (this *app) Init() {
|
||||
f5.LoadMetaTable(mt.Table)
|
||||
this.registerDataSources()
|
||||
db.InitDB()
|
||||
ginMgr.init()
|
||||
//ginMgr.init()
|
||||
}
|
||||
|
||||
func (this *App) UnInit() {
|
||||
ginMgr.unInit()
|
||||
func (this *app) UnInit() {
|
||||
//ginMgr.unInit()
|
||||
}
|
||||
|
||||
func (this *App) Update() {
|
||||
func (this *app) Update() {
|
||||
}
|
||||
|
||||
func (this *App) registerDataSources() {
|
||||
func (this *app) registerDataSources() {
|
||||
f5.GetJsStyleDb().RegisterDataSource(
|
||||
GAME_DB,
|
||||
constant.GAME_DB,
|
||||
mt.Table.GameDb.GetById(0).GetHost(),
|
||||
mt.Table.GameDb.GetById(0).GetPort(),
|
||||
mt.Table.GameDb.GetById(0).GetUser(),
|
||||
@ -37,7 +36,7 @@ func (this *App) registerDataSources() {
|
||||
mt.Table.GameDb.GetById(0).GetDatabase(),
|
||||
30)
|
||||
f5.GetJsStyleDb().RegisterDataSource(
|
||||
FRIEND_DB,
|
||||
constant.FRIEND_DB,
|
||||
mt.Table.FriendDb.GetById(0).GetHost(),
|
||||
mt.Table.FriendDb.GetById(0).GetPort(),
|
||||
mt.Table.FriendDb.GetById(0).GetUser(),
|
||||
|
12
server/adminserver/app/export.go
Normal file
12
server/adminserver/app/export.go
Normal file
@ -0,0 +1,12 @@
|
||||
package app
|
||||
|
||||
import (
|
||||
"main/constant"
|
||||
"main/global"
|
||||
)
|
||||
|
||||
var _app = new(app)
|
||||
|
||||
func init() {
|
||||
global.RegModule(constant.APP_MODULE_IDX, _app)
|
||||
}
|
5
server/adminserver/common/types.go
Normal file
5
server/adminserver/common/types.go
Normal file
@ -0,0 +1,5 @@
|
||||
package common
|
||||
|
||||
type App interface {
|
||||
Run(func(), func())
|
||||
}
|
@ -8,3 +8,8 @@ const (
|
||||
GAME_DB = "gamedb"
|
||||
FRIEND_DB = "firenddb"
|
||||
)
|
||||
|
||||
const (
|
||||
APP_MODULE_IDX = iota
|
||||
MAX_MODULE_IDX
|
||||
)
|
||||
|
47
server/adminserver/global/global.go
Normal file
47
server/adminserver/global/global.go
Normal file
@ -0,0 +1,47 @@
|
||||
package global
|
||||
|
||||
import (
|
||||
"q5"
|
||||
"fmt"
|
||||
"main/constant"
|
||||
"main/common"
|
||||
)
|
||||
|
||||
var modules [constant.MAX_MODULE_IDX]q5.Module
|
||||
var initOrders = []int32 {
|
||||
}
|
||||
|
||||
var app common.App
|
||||
|
||||
func GetApp() common.App {
|
||||
return app
|
||||
}
|
||||
|
||||
func RegModule(idx int32, m q5.Module) {
|
||||
fmt.Printf("RegModule module %d\n", idx)
|
||||
modules[idx] = m
|
||||
switch (idx) {
|
||||
case constant.APP_MODULE_IDX:
|
||||
{
|
||||
app = m.(common.App)
|
||||
}
|
||||
default:
|
||||
{
|
||||
panic("unknow module")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func InitModules() {
|
||||
for _, val := range(initOrders) {
|
||||
fmt.Printf("init module %d\n", val)
|
||||
modules[val].Init()
|
||||
}
|
||||
}
|
||||
|
||||
func UnInitModules() {
|
||||
for _, val := range(initOrders) {
|
||||
fmt.Printf("unInit module %d", val)
|
||||
modules[val].UnInit()
|
||||
}
|
||||
}
|
@ -1,5 +1,11 @@
|
||||
package initialize
|
||||
|
||||
func Init() {
|
||||
import (
|
||||
_ "main/app"
|
||||
|
||||
. "main/global"
|
||||
)
|
||||
|
||||
func Init() {
|
||||
GetApp().Run(InitModules, UnInitModules)
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user