diff options
author | ttys3 <41882455+ttys3@users.noreply.github.com> | 2022-05-04 19:56:20 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-05-04 14:56:20 +0300 |
commit | e933f314268e41477c85e44a255667c02b19f231 (patch) | |
tree | 23a610cffe6e2c5ef01ca677c391f1f8b86fe824 /routers/install | |
parent | 3114cd30b817692556306ce6261ace2b58c54b76 (diff) | |
download | gitea-e933f314268e41477c85e44a255667c02b19f231.tar.gz gitea-e933f314268e41477c85e44a255667c02b19f231.zip |
Add health check endpoint (#18465)
* chore: add health check endpoint
docs: update document about health check
fix: fix up Sqlite3 ping. current ping will success even if the db file is missing
fix: do not expose privacy information in output field
* refactor: remove HealthChecker struct
* Added `/api/healthz` to install routes.
This was needed for using /api/healthz endpoint in Docker healthchecks,
otherwise, Docker would never become healthy if using healthz endpoint
and users would not be able to complete the installation of Gitea.
* Update modules/cache/cache.go
* fine tune
* Remove unnecessary test code. Now there are 2 routes for installation (and maybe more in future)
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
Co-authored-by: 6543 <6543@obermui.de>
Co-authored-by: Marcos de Oliveira <marcossantos@furb.br>
Diffstat (limited to 'routers/install')
-rw-r--r-- | routers/install/routes.go | 2 | ||||
-rw-r--r-- | routers/install/routes_test.go | 1 |
2 files changed, 2 insertions, 1 deletions
diff --git a/routers/install/routes.go b/routers/install/routes.go index ef96e99628..e77081afe0 100644 --- a/routers/install/routes.go +++ b/routers/install/routes.go @@ -16,6 +16,7 @@ import ( "code.gitea.io/gitea/modules/web" "code.gitea.io/gitea/modules/web/middleware" "code.gitea.io/gitea/routers/common" + "code.gitea.io/gitea/routers/web/healthcheck" "code.gitea.io/gitea/services/forms" "gitea.com/go-chi/session" @@ -106,6 +107,7 @@ func Routes() *web.Route { r.Use(Init) r.Get("/", Install) r.Post("/", web.Bind(forms.InstallForm{}), SubmitInstall) + r.Get("/api/healthz", healthcheck.Check) r.NotFound(web.Wrap(installNotFound)) return r diff --git a/routers/install/routes_test.go b/routers/install/routes_test.go index 35a66c1c47..29003c3841 100644 --- a/routers/install/routes_test.go +++ b/routers/install/routes_test.go @@ -13,7 +13,6 @@ import ( func TestRoutes(t *testing.T) { routes := Routes() assert.NotNil(t, routes) - assert.Len(t, routes.R.Routes(), 1) assert.EqualValues(t, "/", routes.R.Routes()[0].Pattern) assert.Nil(t, routes.R.Routes()[0].SubRoutes) assert.Len(t, routes.R.Routes()[0].Handlers, 2) |