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.

40 lines
753 B

  1. package cmd
  2. import (
  3. "github.com/arnaucube/gogame/config"
  4. "github.com/arnaucube/gogame/database"
  5. "github.com/arnaucube/gogame/endpoint"
  6. "github.com/arnaucube/gogame/services/usersrv"
  7. "github.com/urfave/cli"
  8. )
  9. var ServerCommands = []cli.Command{
  10. {
  11. Name: "start",
  12. Aliases: []string{},
  13. Usage: "start the server",
  14. Action: start,
  15. },
  16. }
  17. func start(c *cli.Context) error {
  18. if err := config.MustRead(c); err != nil {
  19. return err
  20. }
  21. db, err := database.New(config.C.Mongodb.Url, config.C.Mongodb.Database)
  22. if err != nil {
  23. return err
  24. }
  25. // services
  26. userservice := usersrv.New(db)
  27. if err != nil {
  28. return err
  29. }
  30. apiService := endpoint.Serve(config.C, db, userservice)
  31. apiService.Run(config.C.Server.ServiceApi)
  32. return nil
  33. }