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) } qemuserver.Setup(s.options.Qemu) webserver.Setup(s.options.WEBServer) <-make(chan int) return nil } 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() }