-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.go
More file actions
40 lines (38 loc) · 783 Bytes
/
main.go
File metadata and controls
40 lines (38 loc) · 783 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
package main
import (
"chat/api"
"chat/connect"
"chat/logic"
"chat/task"
"flag"
"fmt"
"os"
"os/signal"
"syscall"
)
func main() {
var module string
flag.StringVar(&module, "module", "", "assign run module")
flag.Parse()
fmt.Println(fmt.Sprintf("start run %s module", module))
switch module {
case "logic":
logic.New().Run()
case "connect_websocket":
connect.New().Run()
case "connect_tcp":
connect.New().RunTcp()
case "task":
task.New().Run()
case "api":
api.New().Run()
default:
fmt.Println("exiting,module param error!")
return
}
fmt.Println(fmt.Sprintf("run %s module done!", module))
quit := make(chan os.Signal)
signal.Notify(quit, syscall.SIGHUP, syscall.SIGINT, syscall.SIGTERM, syscall.SIGQUIT)
<-quit
fmt.Println("Server exiting")
}