diff options
author | Evan Sherwood <neezer@users.noreply.github.com> | 2018-04-04 02:34:27 -0700 |
---|---|---|
committer | Lunny Xiao <xiaolunwen@gmail.com> | 2018-04-04 17:34:27 +0800 |
commit | 6b6c414bc370dc61a599b2ccfc62f5f726a5176c (patch) | |
tree | 3c36dd165e0a99b093c21fc0089990ca1c248f2a /models | |
parent | 3e06490d38ee631029b020ccd408231841e5d1da (diff) | |
download | gitea-6b6c414bc370dc61a599b2ccfc62f5f726a5176c.tar.gz gitea-6b6c414bc370dc61a599b2ccfc62f5f726a5176c.zip |
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>
Diffstat (limited to 'models')
-rw-r--r-- | models/models.go | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/models/models.go b/models/models.go index b2f5e923e7..549d2eadc9 100644 --- a/models/models.go +++ b/models/models.go @@ -335,7 +335,10 @@ func GetStatistic() (stats Statistic) { // Ping tests if database is alive func Ping() error { - return x.Ping() + if x != nil { + return x.Ping() + } + return errors.New("database not configured") } // DumpDatabase dumps all data from database according the special database SQL syntax to file system. |