38 lines
738 B
Go
38 lines
738 B
Go
|
package cmd
|
||
|
|
||
|
import (
|
||
|
"context"
|
||
|
|
||
|
"esway/internal/api"
|
||
|
"esway/internal/controller"
|
||
|
"esway/internal/database/cache"
|
||
|
"esway/internal/database/db"
|
||
|
"esway/internal/gateway"
|
||
|
"esway/internal/log"
|
||
|
"esway/internal/model"
|
||
|
"esway/internal/opt"
|
||
|
"esway/internal/tool"
|
||
|
)
|
||
|
|
||
|
func execute(ctx context.Context) error {
|
||
|
tool.Must(opt.Init(opt.Cfg.Config))
|
||
|
tool.Must(db.Init(ctx, opt.Cfg.DB.Uri))
|
||
|
tool.Must(cache.Init())
|
||
|
|
||
|
tool.Must(model.Init(db.Default.Session()))
|
||
|
tool.Must(controller.Init(ctx))
|
||
|
tool.Must(gateway.Start(ctx))
|
||
|
tool.Must(api.Start(ctx))
|
||
|
|
||
|
<-ctx.Done()
|
||
|
|
||
|
log.Warn(ctx, "received quit signal...(2s)")
|
||
|
<-tool.Timeout(2).Done()
|
||
|
|
||
|
return nil
|
||
|
}
|
||
|
|
||
|
func Execute(ctx context.Context) error {
|
||
|
return rootCommand.ExecuteContext(ctx)
|
||
|
}
|