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)
44 lines
964 B
Go
44 lines
964 B
Go
package main
|
|
|
|
import (
|
|
"context"
|
|
"flag"
|
|
"log"
|
|
"os"
|
|
|
|
"github.com/CPunch/gopenfusion/config"
|
|
"github.com/CPunch/gopenfusion/core/db"
|
|
"github.com/CPunch/gopenfusion/core/redis"
|
|
|
|
"github.com/google/subcommands"
|
|
)
|
|
|
|
var dbHndlr *db.DBHandler
|
|
var redisHndlr *redis.RedisHandler
|
|
|
|
func main() {
|
|
subcommands.Register(subcommands.HelpCommand(), "")
|
|
subcommands.Register(subcommands.FlagsCommand(), "")
|
|
subcommands.Register(subcommands.CommandsCommand(), "")
|
|
subcommands.Register(&shardCommand{}, "")
|
|
subcommands.Register(&loginCommand{}, "")
|
|
|
|
var err error
|
|
dbHndlr, err = db.OpenPostgresDB(config.GetDBAddr())
|
|
if err != nil {
|
|
log.Panicf("failed to open db: %v", err)
|
|
}
|
|
|
|
if err = dbHndlr.Setup(); err != nil {
|
|
log.Panicf("failed to setup db: %v", err)
|
|
}
|
|
|
|
redisHndlr, err = redis.OpenRedis(config.GetRedisAddr())
|
|
if err != nil {
|
|
log.Panicf("failed to open redis: %v", err)
|
|
}
|
|
|
|
flag.Parse()
|
|
os.Exit(int(subcommands.Execute(context.Background())))
|
|
}
|