-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathmain.go
46 lines (36 loc) · 1015 Bytes
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
package main
import (
"INServer/src/cli"
"INServer/src/common/global"
"INServer/src/common/logger"
"INServer/src/common/profiler"
"INServer/src/lifetime/finalize"
"INServer/src/lifetime/startup"
_ "expvar"
"flag"
"fmt"
"log"
"runtime"
)
var serverID = flag.Int("id", -1, "本服务器ID(范围0~65535)")
var centerIP = flag.String("center", "127.0.0.1", "中心服务器IP")
var interactive = flag.Bool("i", false, "开启交互命令行")
func main() {
runtime.GOMAXPROCS(1)
flag.Parse()
global.CurrentServerID = int32(*serverID)
global.CenterIP = *centerIP
if global.CurrentServerID == -1 {
log.Fatalln("必须使用参数(-id ?)指定本服务器ID")
} else if global.CurrentServerID > global.SERVER_ID_MAX || global.CurrentServerID < 0 {
log.Fatalln("服务器ID范围0~999")
}
logger.Setup()
profiler.Start()
startup.Run()
if *interactive {
go cli.Run()
}
finalize.Wait()
logger.Info(fmt.Sprintf("%d-%s Shut Down!", global.CurrentServerID, global.CurrentServerType))
}