2017-04-19 18:19:27 +08:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
2017-05-09 18:17:08 +08:00
|
|
|
"fmt"
|
|
|
|
"os"
|
2017-05-11 13:39:34 +08:00
|
|
|
|
2017-05-03 15:05:01 +08:00
|
|
|
_ "github.com/astaxie/beego/session/memcache"
|
|
|
|
_ "github.com/astaxie/beego/session/mysql"
|
2017-05-11 13:39:34 +08:00
|
|
|
_ "github.com/astaxie/beego/session/redis"
|
|
|
|
_ "github.com/go-sql-driver/mysql"
|
2017-06-02 16:08:14 +08:00
|
|
|
"github.com/kardianos/service"
|
2017-06-14 09:23:29 +08:00
|
|
|
"github.com/lifei6671/mindoc/commands"
|
|
|
|
"github.com/lifei6671/mindoc/commands/daemon"
|
|
|
|
_ "github.com/lifei6671/mindoc/routers"
|
2017-05-20 09:52:18 +08:00
|
|
|
_ "github.com/mattn/go-sqlite3"
|
2017-04-19 18:19:27 +08:00
|
|
|
)
|
|
|
|
|
|
|
|
func main() {
|
2017-05-01 17:43:33 +08:00
|
|
|
|
2017-06-02 16:08:14 +08:00
|
|
|
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()
|
|
|
|
}
|
|
|
|
}
|
2017-04-21 18:20:35 +08:00
|
|
|
commands.RegisterCommand()
|
|
|
|
|
2017-06-02 16:08:14 +08:00
|
|
|
d := daemon.NewDaemon()
|
2017-05-01 19:12:52 +08:00
|
|
|
|
2017-06-02 16:08:14 +08:00
|
|
|
s, err := service.New(d, d.Config())
|
2017-05-10 13:43:36 +08:00
|
|
|
|
2017-06-02 16:08:14 +08:00
|
|
|
if err != nil {
|
|
|
|
fmt.Println("Create service error => ", err)
|
|
|
|
os.Exit(1)
|
|
|
|
}
|
2017-05-11 13:39:34 +08:00
|
|
|
|
2017-06-02 16:08:14 +08:00
|
|
|
s.Run()
|
2017-04-19 18:19:27 +08:00
|
|
|
}
|