main.go 751 B

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