2023-06-22 06:53:38 +00:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
"flag"
|
|
|
|
"log"
|
|
|
|
"os"
|
|
|
|
|
2023-12-03 04:09:11 +00:00
|
|
|
"github.com/CPunch/gopenfusion/internal/config"
|
2023-08-23 23:16:24 +00:00
|
|
|
"github.com/CPunch/gopenfusion/internal/db"
|
|
|
|
"github.com/CPunch/gopenfusion/internal/redis"
|
2023-06-22 06:53:38 +00:00
|
|
|
|
|
|
|
"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())))
|
|
|
|
}
|