gopenfusion/cmd/login.go
unknown d7445e0f0f Switched to redis/postgres, major refactoring
- loginMetadata is passed to shards through redis now
- shards announce they're alive via redis.AnnounceShard() which just
  populates a hashset keyed 'shards'
- login servers grab the 'shards' hashset and randomly picks a shard to
  pass the player to (for now)
- ./service shard && ./service login
- Many new environment variables, check config/config.go for more info.
  or for a tl;dr just read the Dockerfile for the required ones
- Shard and login services now run in different processes ! (and
  containers?? wooaaah)
2023-06-22 01:53:38 -05:00

43 lines
880 B
Go

package main
import (
"context"
"flag"
"log"
"github.com/CPunch/gopenfusion/config"
"github.com/CPunch/gopenfusion/login"
"github.com/google/subcommands"
)
type loginCommand struct {
port int
}
func (s *loginCommand) Name() string {
return "login"
}
func (s *loginCommand) Synopsis() string {
return "Starts login service"
}
func (s *loginCommand) Usage() string {
return s.Name() + " - " + s.Synopsis() + ":\n"
}
func (s *loginCommand) SetFlags(f *flag.FlagSet) {
f.IntVar(&s.port, "port", config.LOGIN_PORT, "Hosts the service on this port")
}
func (s *loginCommand) Execute(ctx context.Context, f *flag.FlagSet, _ ...interface{}) subcommands.ExitStatus {
loginServer, err := login.NewLoginServer(dbHndlr, redisHndlr, s.port)
if err != nil {
log.Panicf("failed to create shard server: %v", err)
}
loginServer.Start()
return subcommands.ExitSuccess
}