main.go
965 Bytes
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
package main
import (
"fmt"
"net/http"
"os"
"os/signal"
"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.SIGUSR1, syscall.SIGUSR2)
s,err1 := NewGameServer(common.GlobalConf.GameConf)
if err1 != nil {
logger.Error(err1)
return
}
go func() {
err <- http.ListenAndServe(fmt.Sprintf("localhost:%d", common.GlobalConf.GameConf.DebugPort), nil)
}()
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())
}
}
}
}