Skip to content

Commit

Permalink
doc: ngx.worker.count() is available in the init_worker_by_lua* context.
Browse files Browse the repository at this point in the history
The `ngx.worker.count` documentation was missing `init_worker_by_lua*` as
a valid context. This updates the documentation and adds a test to
demonstrate that this method does in fact work in the
`init_worker_by_lua` context.

Signed-off-by: Yichun Zhang (agentzh) <agentzh@gmail.com>
  • Loading branch information
GUI authored and agentzh committed Jul 31, 2016
1 parent b9bd802 commit c5ada99
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
2 changes: 1 addition & 1 deletion README.markdown
Expand Up @@ -7565,7 +7565,7 @@ ngx.worker.count

**syntax:** *count = ngx.worker.count()*

**context:** *set_by_lua&#42;, rewrite_by_lua&#42;, access_by_lua&#42;, content_by_lua&#42;, header_filter_by_lua&#42;, body_filter_by_lua&#42;, log_by_lua&#42;, ngx.timer.&#42;, init_by_lua&#42;*
**context:** *set_by_lua&#42;, rewrite_by_lua&#42;, access_by_lua&#42;, content_by_lua&#42;, header_filter_by_lua&#42;, body_filter_by_lua&#42;, log_by_lua&#42;, ngx.timer.&#42;, init_by_lua&#42;, init_worker_by_lua&#42;*

Returns the total number of the Nginx worker processes (i.e., the value configured
by the [worker_processes](http://nginx.org/en/docs/ngx_core_module.html#worker_processes)
Expand Down
20 changes: 20 additions & 0 deletions t/133-worker-count.t
Expand Up @@ -50,3 +50,23 @@ GET /lua
workers: 1
--- no_error_log
[error]



=== TEST 3: init_worker_by_lua
--- http_config
init_worker_by_lua_block {
init_worker_count = ngx.worker.count()
}
--- config
location /lua {
content_by_lua_block {
ngx.say("workers: ", init_worker_count)
}
}
--- request
GET /lua
--- response_body
workers: 1
--- no_error_log
[error]

0 comments on commit c5ada99

Please sign in to comment.