ops: added healthcheck view

This commit is contained in:
RhodeCode Admin 2021-10-12 14:29:26 +02:00
parent f5cf1a1f86
commit 720dbed814
3 changed files with 30 additions and 1 deletions

View file

@ -51,6 +51,14 @@ def admin_routes(config):
route_name='ops_redirect_test', request_method='GET',
renderer='json_ext')
config.add_route(
name='ops_healthcheck',
pattern='/status')
config.add_view(
OpsView,
attr='ops_healthcheck',
route_name='ops_healthcheck', request_method='GET',
renderer='json_ext')
def includeme(config):
config.include(admin_routes, route_prefix=ADMIN_PREFIX + '/ops')

View file

@ -72,3 +72,23 @@ class OpsView(BaseAppView):
"""
redirect_to = self.request.GET.get('to') or h.route_path('home')
raise HTTPFound(redirect_to)
def ops_healthcheck(self):
from rhodecode.lib.system_info import load_system_info
vcsserver_info = load_system_info('vcs_server')
if vcsserver_info:
vcsserver_info = vcsserver_info['human_value']
db_info = load_system_info('database_info')
if db_info:
db_info = db_info['human_value']
health_spec = {
'caller_ip': self.request.user.ip_addr,
'vcsserver': vcsserver_info,
'db': db_info,
}
return {'healthcheck': health_spec}

View file

@ -166,8 +166,9 @@ def detect_vcs_request(environ, backends):
# static files no detection
'_static',
# skip ops ping
# skip ops ping, status
'_admin/ops/ping',
'_admin/ops/status',
# full channelstream connect should be VCS skipped
'_admin/channelstream/connect',