gopenfusion/cmd/shard.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/shard"
"github.com/google/subcommands"
)
type shardCommand struct {
port int
}
func (s *shardCommand) Name() string {
return "shard"
}
func (s *shardCommand) Synopsis() string {
return "Starts shard service"
}
func (s *shardCommand) Usage() string {
return s.Name() + " - " + s.Synopsis() + ":\n"
}
func (s *shardCommand) SetFlags(f *flag.FlagSet) {
f.IntVar(&s.port, "port", config.SHARD_PORT, "Hosts the service on this port")
}
func (s *shardCommand) Execute(ctx context.Context, f *flag.FlagSet, _ ...interface{}) subcommands.ExitStatus {
shardServer, err := shard.NewShardServer(dbHndlr, redisHndlr, s.port)
if err != nil {
log.Panicf("failed to create shard server: %v", err)
}
shardServer.Start()
return subcommands.ExitSuccess
}