mirror of
https://github.com/CPunch/gopenfusion.git
synced 2024-11-21 23:10:06 +00:00
44 lines
981 B
Go
44 lines
981 B
Go
package main
|
|
|
|
import (
|
|
"context"
|
|
"flag"
|
|
"log"
|
|
"os"
|
|
|
|
"github.com/CPunch/gopenfusion/internal/config"
|
|
"github.com/CPunch/gopenfusion/internal/db"
|
|
"github.com/CPunch/gopenfusion/internal/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())))
|
|
}
|