forked from vaxilu/x-ui
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
55 lines (46 loc) · 917 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
47
48
49
50
51
52
53
54
55
package main
import (
"github.com/op/go-logging"
"log"
"os"
"os/signal"
"syscall"
"x-ui/config"
"x-ui/database"
"x-ui/logger"
"x-ui/web"
)
func main() {
log.Printf("%v %v", config.GetName(), config.GetVersion())
switch config.GetLogLevel() {
case config.Debug:
logger.InitLogger(logging.DEBUG)
case config.Info:
logger.InitLogger(logging.INFO)
case config.Warn:
logger.InitLogger(logging.WARNING)
case config.Error:
logger.InitLogger(logging.ERROR)
default:
log.Fatal("unknown log level:", config.GetLogLevel())
}
err := database.InitDB(config.GetDBPath())
if err != nil {
log.Fatal(err)
}
var server *web.Server
server = web.NewServer()
go server.Run()
sigCh := make(chan os.Signal, 1)
signal.Notify(sigCh, syscall.SIGHUP)
for {
sig := <-sigCh
if sig == syscall.SIGHUP {
server.Stop()
server = web.NewServer()
go server.Run()
} else {
return
}
}
}