diff --git a/CHANGELOG.md b/CHANGELOG.md index d74c3e12b..00c38272b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,6 +17,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/). - Backend HTTP client that uses cosockets [PR #295](https://github.com/3scale/apicast/pull/295) - Ability to customize main section of nginx configuration (and expose more env variables) [PR #292](https://github.com/3scale/apicast/pull/292) - Ability to lock service to specific configuration version [PR #293](https://github.com/3scale/apicast/pull/292) +- Experimental option for true out of band reporting (`APICAST_REPORTING_WORKERS`) [PR #290](https://github.com/3scale/apicast/pull/290) +- `/status/info` endpoint to the Management API [PR #290](https://github.com/3scale/apicast/pull/290) ### Removed diff --git a/apicast/src/management.lua b/apicast/src/management.lua index 13ec8c5be..7e2dda499 100644 --- a/apicast/src/management.lua +++ b/apicast/src/management.lua @@ -113,6 +113,20 @@ function _M.disabled() ngx.exit(ngx.HTTP_FORBIDDEN) end +function _M.info() + return json_response({ + timers = { + pending = ngx.timer.pending_count(), + running = ngx.timer.running_count() + }, + worker = { + exiting = ngx.worker.exiting(), + count = ngx.worker.count(), + id = ngx.worker.id() + } + }) +end + local routes = {} function routes.disabled(r) @@ -120,6 +134,7 @@ function routes.disabled(r) end function routes.status(r) + r:get('/status/info', _M.info) r:get('/status/ready', _M.ready) r:get('/status/live', _M.live) end diff --git a/doc/management-api.md b/doc/management-api.md index 1abd6fbaf..b1f8d24e3 100644 --- a/doc/management-api.md +++ b/doc/management-api.md @@ -82,3 +82,13 @@ Available endpoints: ```json { "status": "live", "success": true } ``` + +- `GET /status/info` + Returns internal information about timers and workers. + + ```json + { + "timers": { "pending": 0, "running": 0 }, + "worker": { "count":1, "exiting": false, "id": 0 } + } + ``` diff --git a/t/001-management.t b/t/001-management.t index 7e4e99e6e..7fcaa7fb0 100644 --- a/t/001-management.t +++ b/t/001-management.t @@ -349,3 +349,19 @@ POST /config --- error_code: 406 --- no_error_log [error] + +=== TEST 16: status information +Has information about timers and time. +--- main_config +env APICAST_MANAGEMENT_API=status; +--- http_config + lua_package_path "$TEST_NGINX_LUA_PATH"; +--- config +include $TEST_NGINX_MANAGEMENT_CONFIG; +--- request +GET /status/info +--- response_body +{"timers":{"pending":0,"running":0},"worker":{"count":1,"exiting":false,"id":0}} +--- error_code: 200 +--- no_error_log +[error]