main.go 831 B

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