Skip to content

Commit

Permalink
add flag harakiri-only-graceful
Browse files Browse the repository at this point in the history
this setting can be useful for cases when graceful harakiri signal is handled by function in app and from that function is raised exception
  • Loading branch information
atwrg committed Feb 7, 2024
1 parent bd25b0a commit ab2c3db
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 1 deletion.
2 changes: 2 additions & 0 deletions core/init.c
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,8 @@ void uwsgi_init_default() {
uwsgi.mule_msg_recv_size = 65536;

uwsgi.harakiri_graceful_signal = SIGTERM;

uwsgi.harakiri_only_graceful = 0;
}

void uwsgi_setup_reload() {
Expand Down
3 changes: 2 additions & 1 deletion core/master_utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -1683,7 +1683,8 @@ void trigger_harakiri(int i) {
}
if (!uwsgi.workers[i].pending_harakiri)
uwsgi.workers[i].harakiri_count++;
uwsgi.workers[i].pending_harakiri++;
if (!uwsgi.harakiri_only_graceful)
uwsgi.workers[i].pending_harakiri++;
}

}
Expand Down
1 change: 1 addition & 0 deletions core/uwsgi.c
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ static struct uwsgi_option uwsgi_base_options[] = {
{"harakiri-verbose", no_argument, 0, "enable verbose mode for harakiri", uwsgi_opt_true, &uwsgi.harakiri_verbose, 0},
{"harakiri-graceful-timeout", required_argument, 0, "interval between graceful harakiri attempt and a sigkill", uwsgi_opt_set_int, &uwsgi.harakiri_graceful_timeout, 0},
{"harakiri-graceful-signal", required_argument, 0, "use this signal instead of sigterm for graceful harakiri attempts", uwsgi_opt_set_int, &uwsgi.harakiri_graceful_signal, 0},
{"harakiri-only-graceful", required_argument, 0, "use only graceful harakiri", uwsgi_opt_true, &uwsgi.harakiri_only_graceful, 0},
{"harakiri-queue-threshold", required_argument, 0, "only trigger harakiri if queue is greater than this threshold", uwsgi_opt_set_int, &uwsgi.harakiri_queue_threshold, 0},
{"harakiri-no-arh", no_argument, 0, "do not enable harakiri during after-request-hook", uwsgi_opt_true, &uwsgi.harakiri_no_arh, 0},
{"no-harakiri-arh", no_argument, 0, "do not enable harakiri during after-request-hook", uwsgi_opt_true, &uwsgi.harakiri_no_arh, 0},
Expand Down
1 change: 1 addition & 0 deletions uwsgi.h
Original file line number Diff line number Diff line change
Expand Up @@ -2488,6 +2488,7 @@ struct uwsgi_server {
int harakiri_verbose;
int harakiri_graceful_timeout;
int harakiri_graceful_signal;
int harakiri_only_graceful;
int harakiri_queue_threshold;
int harakiri_no_arh;

Expand Down

0 comments on commit ab2c3db

Please sign in to comment.