You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

35 lines
923 B

4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
  1. package app
  2. import (
  3. "context"
  4. "fmt"
  5. "git.aiterp.net/lucifer/new-server/app/api"
  6. "git.aiterp.net/lucifer/new-server/app/config"
  7. "git.aiterp.net/lucifer/new-server/app/services"
  8. "git.aiterp.net/lucifer/new-server/app/services/scene"
  9. "github.com/gin-gonic/gin"
  10. "log"
  11. )
  12. func StartServer() {
  13. services.StartEventHandler()
  14. services.StartPublisher()
  15. services.ConnectToBridges()
  16. services.CheckNewDevices()
  17. go scene.GlobalManager().Run(context.Background())
  18. gin.SetMode(gin.ReleaseMode)
  19. ginny := gin.New()
  20. apiGin := ginny.Group("/api")
  21. api.Bridges(apiGin.Group("/bridges"))
  22. api.Devices(apiGin.Group("/devices"))
  23. api.ColorPresets(apiGin.Group("/color-presets"))
  24. api.DriverKinds(apiGin.Group("/driver-kinds"))
  25. api.Events(apiGin.Group("/events"))
  26. api.EventHandlers(apiGin.Group("/event-handlers"))
  27. api.Scenes(apiGin.Group("/scenes"))
  28. log.Fatal(ginny.Run(fmt.Sprintf("0.0.0.0:%d", config.ServerPort())))
  29. }