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.
 
 
 

42 lines
859 B

package cmd
import (
"github.com/arnaucube/gogame/config"
"github.com/arnaucube/gogame/database"
"github.com/arnaucube/gogame/endpoint"
"github.com/arnaucube/gogame/services/gamesrv"
"github.com/arnaucube/gogame/services/usersrv"
"github.com/urfave/cli"
)
var ServerCommands = []cli.Command{
{
Name: "start",
Aliases: []string{},
Usage: "start the server",
Action: start,
},
}
func start(c *cli.Context) error {
if err := config.MustRead(c); err != nil {
return err
}
db, err := database.New(config.C.Mongodb.Url, config.C.Mongodb.Database)
if err != nil {
return err
}
// services
gameservice := gamesrv.New(db)
userservice := usersrv.New(db, gameservice)
if err != nil {
return err
}
apiService := endpoint.Serve(config.C, db, userservice, gameservice)
apiService.Run(config.C.Server.ServiceApi)
return nil
}