Skip to content

Commit

Permalink
services fix
Browse files Browse the repository at this point in the history
  • Loading branch information
axiaoxin committed Nov 23, 2020
1 parent 206f4cd commit 4f788ba
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions src/services/services_health.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,15 @@ import (

// CheckMySQL 检查 mysql 服务状态
func CheckMySQL(ctx context.Context) map[string]string {
// 检查本地 mysql
localhostMySQLStatus := "ok"
if localhostMySQL, err := GormMySQL("localhost"); err != nil {
localhostMySQLStatus = err.Error()
} else if sqlDB, err := localhostMySQL.DB(); err != nil {
localhostMySQLStatus = err.Error()
// 检查默认 mysql
defaultMySQLStatus := "ok"
if sqlDB, err := DB(ctx).DB(); err != nil {
defaultMySQLStatus = err.Error()
} else if err := sqlDB.Ping(); err != nil {
localhostMySQLStatus = err.Error()
defaultMySQLStatus = err.Error()
}
return map[string]string{
"localhost": localhostMySQLStatus,
"default DB": defaultMySQLStatus,
}
}

Expand Down

0 comments on commit 4f788ba

Please sign in to comment.