# HG changeset patch # User RhodeCode Admin # Date 2021-10-12 12:29:26 # Node ID d501e9ec06c8c689b95ca4cb0fc1fd667461771a # Parent fd8f99cdf76a67d7949cbf10c0be5f97be88ad57 ops: added healthcheck view diff --git a/rhodecode/apps/ops/__init__.py b/rhodecode/apps/ops/__init__.py --- a/rhodecode/apps/ops/__init__.py +++ b/rhodecode/apps/ops/__init__.py @@ -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') diff --git a/rhodecode/apps/ops/views.py b/rhodecode/apps/ops/views.py --- a/rhodecode/apps/ops/views.py +++ b/rhodecode/apps/ops/views.py @@ -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} + diff --git a/rhodecode/lib/middleware/vcs.py b/rhodecode/lib/middleware/vcs.py --- a/rhodecode/lib/middleware/vcs.py +++ b/rhodecode/lib/middleware/vcs.py @@ -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',