main.go
1.08 KB
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
47
48
49
50
51
52
53
54
55
56
57
58
package main
import (
"fmt"
"net/http"
"os"
"os/signal"
"pro2d/cmd/gameserver/service"
"pro2d/common"
"pro2d/common/logger"
"syscall"
)
func main() {
err := make(chan error)
stopChan := make(chan os.Signal)
signal.Notify(stopChan, syscall.SIGTERM, syscall.SIGINT, syscall.SIGKILL)
userChan := make(chan os.Signal)
signal.Notify(userChan, syscall.SIGQUIT)
common.GlobalSconf = common.GlobalConf.GameConf
s, err1 := service.NewGameServer()
if err1 != nil {
logger.Error(err1)
return
}
go func() {
err <- http.ListenAndServe(fmt.Sprintf(":%d", common.GlobalSconf.DebugPort), nil)
}()
gm := service.NewGmServer(s, fmt.Sprintf(":%d", common.GlobalSconf.GMPort))
go func() {
err <- gm.Start()
}()
go func() {
err <- s.Start()
}()
for {
select {
case e := <-err:
logger.Error("game server error: %v", e)
return
case <-stopChan:
logger.Debug("game stop...")
s.Stop()
return
case u := <-userChan:
logger.Debug("userChan .. %v", u.String())
e := s.IServer.GetPlugin().LoadPlugin()
if e != nil {
logger.Error("err: ", e.Error())
}
}
}
}