chore: update server activity (#898)

This commit is contained in:
boojack
2023-01-03 20:05:37 +08:00
committed by GitHub
parent e5550828a0
commit 79180928d4
4 changed files with 50 additions and 28 deletions

View File

@@ -26,8 +26,19 @@ const (
`
)
func run(profile *profile.Profile) error {
func run() error {
ctx := context.Background()
profile, err := profile.GetProfile()
if err != nil {
return err
}
println("---")
println("profile")
println("mode:", profile.Mode)
println("port:", profile.Port)
println("dsn:", profile.DSN)
println("version:", profile.Version)
println("---")
db := DB.NewDB(profile)
if err := db.Open(ctx); err != nil {
@@ -48,30 +59,9 @@ func run(profile *profile.Profile) error {
return serverInstance.Run(ctx)
}
func execute() error {
profile, err := profile.GetProfile()
if err != nil {
return err
}
println("---")
println("profile")
println("mode:", profile.Mode)
println("port:", profile.Port)
println("dsn:", profile.DSN)
println("version:", profile.Version)
println("---")
if err := run(profile); err != nil {
fmt.Printf("error: %+v\n", err)
return err
}
return nil
}
func main() {
if err := execute(); err != nil {
if err := run(); err != nil {
fmt.Printf("error: %+v\n", err)
os.Exit(1)
}
}