mirror of
https://github.com/CPunch/gopenfusion.git
synced 2024-11-10 02:20:05 +00:00
unknown
d7445e0f0f
- 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)
43 lines
880 B
Go
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
|
|
}
|