main.go 868 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  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/go-sql-driver/mysql"
  9. "github.com/kardianos/service"
  10. "github.com/lifei6671/mindoc/commands"
  11. "github.com/lifei6671/mindoc/commands/daemon"
  12. _ "github.com/lifei6671/mindoc/routers"
  13. _ "github.com/lifei6671/mindoc/acl"
  14. _ "github.com/mattn/go-sqlite3"
  15. )
  16. func main() {
  17. if len(os.Args) >= 3 && os.Args[1] == "service" {
  18. if os.Args[2] == "install" {
  19. daemon.Install()
  20. } else if os.Args[2] == "remove" {
  21. daemon.Uninstall()
  22. } else if os.Args[2] == "restart" {
  23. daemon.Restart()
  24. }
  25. }
  26. commands.RegisterCommand()
  27. d := daemon.NewDaemon()
  28. s, err := service.New(d, d.Config())
  29. if err != nil {
  30. fmt.Println("Create service error => ", err)
  31. os.Exit(1)
  32. }
  33. s.Run()
  34. }