Enhance healthcheck for database connectivity (#3754)
Modify the call to ping the database to fail gracefully if the database has not yet been configured by the end user, such as after a clean install. This allows /healthcheck to return a 200 with a modified status message instead of causing a PANIC. Signed-off-by: Evan Sherwood <evan@sherwood.io>
This commit is contained in:
parent
3e06490d38
commit
6b6c414bc3
1 changed files with 4 additions and 1 deletions
|
@ -335,8 +335,11 @@ func GetStatistic() (stats Statistic) {
|
||||||
|
|
||||||
// Ping tests if database is alive
|
// Ping tests if database is alive
|
||||||
func Ping() error {
|
func Ping() error {
|
||||||
|
if x != nil {
|
||||||
return x.Ping()
|
return x.Ping()
|
||||||
}
|
}
|
||||||
|
return errors.New("database not configured")
|
||||||
|
}
|
||||||
|
|
||||||
// DumpDatabase dumps all data from database according the special database SQL syntax to file system.
|
// DumpDatabase dumps all data from database according the special database SQL syntax to file system.
|
||||||
func DumpDatabase(filePath string, dbType string) error {
|
func DumpDatabase(filePath string, dbType string) error {
|
||||||
|
|
Reference in a new issue