forked from mindoc-org/mindoc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
43 lines (35 loc) · 910 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
package main
import (
"fmt"
"log"
"os"
_ "github.com/beego/beego/v2/server/web/session/memcache"
_ "github.com/beego/beego/v2/server/web/session/mysql"
_ "github.com/beego/beego/v2/server/web/session/redis"
"github.com/kardianos/service"
_ "github.com/mattn/go-sqlite3"
"github.com/mindoc-org/mindoc/commands"
"github.com/mindoc-org/mindoc/commands/daemon"
_ "github.com/mindoc-org/mindoc/routers"
)
func main() {
if len(os.Args) >= 3 && os.Args[1] == "service" {
if os.Args[2] == "install" {
daemon.Install()
} else if os.Args[2] == "remove" {
daemon.Uninstall()
} else if os.Args[2] == "restart" {
daemon.Restart()
}
}
commands.RegisterCommand()
d := daemon.NewDaemon()
s, err := service.New(d, d.Config())
if err != nil {
fmt.Println("Create service error => ", err)
os.Exit(1)
}
if err := s.Run(); err != nil {
log.Fatal("启动程序失败 ->", err)
}
}