-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.go
More file actions
36 lines (33 loc) · 794 Bytes
/
Copy pathmain.go
File metadata and controls
36 lines (33 loc) · 794 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
package main
import (
"flag"
"fmt"
"github.com/OliCoder/RecSys/engine"
router "github.com/OliCoder/RecSys/router"
"github.com/OliCoder/RecSys/settings"
log "github.com/sirupsen/logrus"
"net/http"
"os"
"os/signal"
)
func main() {
flag.Parse()
r := router.InitRouter()
server := &http.Server{
Addr: fmt.Sprintf(":%s", settings.GetConfigInstance().ServerPort),
Handler: r,
ReadTimeout: settings.GetConfigInstance().ServerReadTimeout,
WriteTimeout: settings.GetConfigInstance().ServerWriteTimeout,
MaxHeaderBytes: 1 << 20,
}
server.ListenAndServe()
c := make(chan os.Signal)
signal.Notify(c, os.Interrupt, os.Kill)
go func() {
for s := range c {
log.Info("Process Exit with %v", s)
engine.ClientTransport.Close()
os.Exit(0)
}
}()
}