forked from arina999999997/elichika
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
50 lines (43 loc) · 962 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
package main
import (
"elichika/config"
_ "elichika/handler"
"elichika/shutdown"
_ "elichika/subsystem"
"elichika/userdata"
_ "elichika/webui"
"elichika/router"
"fmt"
"os"
"runtime"
"github.com/gin-gonic/gin"
)
// with some cli, we keep the server open
// return true to keep open
func checkCli() bool {
if os.Args[1] == "rebuild_assets" {
if len(os.Args) > 2 && os.Args[2] == "keep_alive" {
return true
}
}
fmt.Println("CLI is reserved for special behaviour, the server will now exit, start it again without any argument!")
return false
}
func main() {
if len(os.Args) > 1 {
if !checkCli() {
return
}
}
userdata.Init()
runtime.GC()
gin.SetMode(gin.ReleaseMode)
r := gin.Default()
router.Router(r)
fmt.Println("server address: ", *config.Conf.ServerAddress)
fmt.Println("WebUI address: ", *config.Conf.ServerAddress+"/webui/...")
go func() {
r.Run(*config.Conf.ServerAddress)
}()
shutdown.ReceiveFinalSignal()
}