-
Notifications
You must be signed in to change notification settings - Fork 2.1k
add exit_worker_by* feature #1682
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
2800b24
add exit_worker_by* feature
f890764
add exit feature
aa18a59
add exit-worker test and exit_worker_by* the manual
d057370
When => when
5eb0771
fix code style
59f94eb
fix 151-exit-worker.t base on iresty/test-nginx
5ec51d0
upgrade markdown and wiki
3d1a8f7
fix exit_worker_by_lua_file HttpLuaModule.wiki
fbb7a70
add NGX_HTTP_LUA_CONTEXT_EXIT_WORKER and tests
rainingmaster f2d3ce3
fix wiki
7f686f4
fix 151-exit-worker.t test
e98f64e
remove 151-exit-worker.t blank line
b8bf381
test: update travis.yaml to pass the test
5aa72f8
test: add some test cases with HUP to reload, and fix the num of cases.
f265995
doc: fix some grammar problem.
rainingmaster 18c3c7d
fix: fix typo
rainingmaster 696b062
doc: add vim modeline in exitworkerbylua.c
rainingmaster 6ec87f1
test(162-exit-worker.t): improve the test cases
rainingmaster 98fb2bb
doc: fix some typo.
rainingmaster 6a7f72b
keep only one blank line before vi:set
rainingmaster cd84502
chore: update doc to reflect APIs is available in exit_worker_by_lua
rainingmaster b9396dc
chore: add introduce for first version of this feature
rainingmaster File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,111 @@ | ||
|
||
/* | ||
* Copyright (C) Yichun Zhang (agentzh) | ||
*/ | ||
|
||
|
||
#ifndef DDEBUG | ||
#define DDEBUG 0 | ||
#endif | ||
#include "ddebug.h" | ||
|
||
|
||
#include "ngx_http_lua_exitworkerby.h" | ||
#include "ngx_http_lua_util.h" | ||
|
||
|
||
void | ||
ngx_http_lua_exit_worker(ngx_cycle_t *cycle) | ||
{ | ||
ngx_http_lua_main_conf_t *lmcf; | ||
ngx_connection_t *c = NULL; | ||
ngx_http_request_t *r = NULL; | ||
ngx_http_lua_ctx_t *ctx; | ||
ngx_http_conf_ctx_t *conf_ctx; | ||
|
||
lmcf = ngx_http_cycle_get_module_main_conf(cycle, ngx_http_lua_module); | ||
if (lmcf == NULL | ||
|| lmcf->exit_worker_handler == NULL | ||
|| lmcf->lua == NULL | ||
#if !(NGX_WIN32) | ||
|| (ngx_process == NGX_PROCESS_HELPER | ||
# ifdef HAVE_PRIVILEGED_PROCESS_PATCH | ||
&& !ngx_is_privileged_agent | ||
# endif | ||
) | ||
#endif /* NGX_WIN32 */ | ||
) | ||
{ | ||
return; | ||
} | ||
|
||
conf_ctx = ((ngx_http_conf_ctx_t *) cycle->conf_ctx[ngx_http_module.index]); | ||
|
||
c = ngx_http_lua_create_fake_connection(NULL); | ||
if (c == NULL) { | ||
goto failed; | ||
} | ||
|
||
c->log = ngx_cycle->log; | ||
|
||
r = ngx_http_lua_create_fake_request(c); | ||
if (r == NULL) { | ||
goto failed; | ||
} | ||
|
||
r->main_conf = conf_ctx->main_conf; | ||
r->srv_conf = conf_ctx->srv_conf; | ||
r->loc_conf = conf_ctx->loc_conf; | ||
|
||
ctx = ngx_http_lua_create_ctx(r); | ||
if (ctx == NULL) { | ||
goto failed; | ||
} | ||
|
||
ctx->context = NGX_HTTP_LUA_CONTEXT_EXIT_WORKER; | ||
ctx->cur_co_ctx = NULL; | ||
|
||
ngx_http_lua_set_req(lmcf->lua, r); | ||
|
||
(void) lmcf->exit_worker_handler(cycle->log, lmcf, lmcf->lua); | ||
|
||
ngx_destroy_pool(c->pool); | ||
return; | ||
|
||
failed: | ||
|
||
if (c) { | ||
ngx_http_lua_close_fake_connection(c); | ||
} | ||
|
||
return; | ||
} | ||
|
||
|
||
ngx_int_t | ||
ngx_http_lua_exit_worker_by_inline(ngx_log_t *log, | ||
ngx_http_lua_main_conf_t *lmcf, lua_State *L) | ||
{ | ||
int status; | ||
|
||
status = luaL_loadbuffer(L, (char *) lmcf->exit_worker_src.data, | ||
lmcf->exit_worker_src.len, "=exit_worker_by_lua") | ||
|| ngx_http_lua_do_call(log, L); | ||
|
||
return ngx_http_lua_report(log, L, status, "exit_worker_by_lua"); | ||
} | ||
|
||
|
||
ngx_int_t | ||
ngx_http_lua_exit_worker_by_file(ngx_log_t *log, ngx_http_lua_main_conf_t *lmcf, | ||
lua_State *L) | ||
{ | ||
int status; | ||
|
||
status = luaL_loadfile(L, (char *) lmcf->exit_worker_src.data) | ||
|| ngx_http_lua_do_call(log, L); | ||
|
||
return ngx_http_lua_report(log, L, status, "exit_worker_by_lua_file"); | ||
} | ||
|
||
/* vi:set ft=c ts=4 sw=4 et fdm=marker: */ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
|
||
/* | ||
* Copyright (C) Yichun Zhang (agentzh) | ||
*/ | ||
|
||
|
||
#ifndef _NGX_HTTP_LUA_EXITWORKERBY_H_INCLUDED_ | ||
#define _NGX_HTTP_LUA_EXITWORKERBY_H_INCLUDED_ | ||
|
||
|
||
#include "ngx_http_lua_common.h" | ||
|
||
|
||
ngx_int_t ngx_http_lua_exit_worker_by_inline(ngx_log_t *log, | ||
ngx_http_lua_main_conf_t *lmcf, lua_State *L); | ||
|
||
ngx_int_t ngx_http_lua_exit_worker_by_file(ngx_log_t *log, | ||
ngx_http_lua_main_conf_t *lmcf, lua_State *L); | ||
|
||
void ngx_http_lua_exit_worker(ngx_cycle_t *cycle); | ||
|
||
|
||
#endif /* _NGX_HTTP_LUA_EXITWORKERBY_H_INCLUDED_ */ | ||
|
||
/* vi:set ft=c ts=4 sw=4 et fdm=marker: */ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.