gopenfusion/cmd/main.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

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())))
}