main.go 795 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. package main
  2. import (
  3. "fmt"
  4. "os"
  5. _ "github.com/astaxie/beego/session/memcache"
  6. _ "github.com/astaxie/beego/session/mysql"
  7. _ "github.com/astaxie/beego/session/redis"
  8. "github.com/kardianos/service"
  9. "github.com/lifei6671/mindoc/commands"
  10. "github.com/lifei6671/mindoc/commands/daemon"
  11. _ "github.com/lifei6671/mindoc/routers"
  12. _ "github.com/mattn/go-sqlite3"
  13. )
  14. func main() {
  15. if len(os.Args) >= 3 && os.Args[1] == "service" {
  16. if os.Args[2] == "install" {
  17. daemon.Install()
  18. } else if os.Args[2] == "remove" {
  19. daemon.Uninstall()
  20. } else if os.Args[2] == "restart" {
  21. daemon.Restart()
  22. }
  23. }
  24. commands.RegisterCommand()
  25. d := daemon.NewDaemon()
  26. s, err := service.New(d, d.Config())
  27. if err != nil {
  28. fmt.Println("Create service error => ", err)
  29. os.Exit(1)
  30. }
  31. s.Run()
  32. }