wip: 登录和认证
This commit is contained in:
@ -6,9 +6,10 @@ import (
|
||||
"loveuer/utodo/internal/model"
|
||||
"loveuer/utodo/internal/opt"
|
||||
g_api "loveuer/utodo/pkg/api"
|
||||
"loveuer/utodo/pkg/database/cache"
|
||||
"loveuer/utodo/pkg/tool"
|
||||
|
||||
"gitea.loveuer.com/yizhisec/packages/database/db"
|
||||
"gitea.loveuer.com/yizhisec/packages/tool"
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
@ -21,6 +22,7 @@ func svcCmd() *cobra.Command {
|
||||
|
||||
cmd.Flags().StringVar(&opt.Cfg.Svc.Address, "address", ":9119", "address to listen on")
|
||||
cmd.Flags().StringVar(&opt.Cfg.Svc.DBFile, "db", "/data/data.db", "database file")
|
||||
cmd.Flags().StringVar(&opt.Cfg.Svc.Cache, "cache", "", "cache uri: empty for memory cache; for redis(rdp://user:password@host:port)")
|
||||
|
||||
return cmd
|
||||
}
|
||||
@ -31,7 +33,14 @@ func svcRun(cmd *cobra.Command, args []string) error {
|
||||
stopApi func(context.Context) error
|
||||
)
|
||||
|
||||
if err = db.Init(db.WithSqlite(opt.Cfg.Svc.DBFile)); err != nil {
|
||||
if err = db.Init(db.WithCtx(cmd.Context()), db.WithSqlite(opt.Cfg.Svc.DBFile)); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if err = cache.Init(
|
||||
cache.WithCtx(cmd.Context()),
|
||||
tool.If(opt.Cfg.Svc.Cache == "", cache.WithMemory(), cache.WithRedisURI(opt.Cfg.Svc.Cache)),
|
||||
); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user