package server import ( "git.sense-t.eu.org/ACE/ace/cmd/config" "git.sense-t.eu.org/ACE/ace/servers/qemuserver" "git.sense-t.eu.org/ACE/ace/servers/webserver" "github.com/gin-gonic/gin" "github.com/sirupsen/logrus" "github.com/urfave/cli/v2" ) type Server struct { options *config.Config } var Command *cli.Command func init() { Command = &cli.Command{ Name: "server", Usage: "run ace server", Action: runServer, } } func NewServer(c *config.Config) (*Server, error) { return &Server{ options: c, }, nil } func (s *Server) Run() error { if s.options.Debug { gin.SetMode(gin.DebugMode) logrus.SetLevel(logrus.DebugLevel) } else { logrus.SetLevel(logrus.InfoLevel) gin.SetMode(gin.ReleaseMode) } qemu, err := qemuserver.NewServer(s.options.Qemu) if err != nil { return err } webServer, err := webserver.NewServer(s.options.WEBServer) if err != nil { return err } webServer.RTCConnector.QEMU = qemu go func() { if err := qemu.Run(); err != nil { logrus.Fatal("cannot run qemuserver with error: ", err) } }() logrus.Debug("qemu server running") return webServer.Run() } func runServer(c *cli.Context) error { config, err := config.ReadConfig(c) if err != nil { return err } server, err := NewServer(config) if err != nil { return err } return server.Run() }