Skip to content
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

graceful stop worker when max_requests/realod_on_* #2615

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions core/loop.c
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,9 @@ void *uwsgi_get_loop(char *name) {

void simple_loop() {
uwsgi_loop_cores_run(simple_loop_run);
// Other threads may still run. Make sure they will stop.
methane marked this conversation as resolved.
Show resolved Hide resolved
uwsgi.workers[uwsgi.mywid].manage_next_request = 0;

if (uwsgi.workers[uwsgi.mywid].shutdown_sockets)
uwsgi_shutdown_all_sockets();
}
Expand Down
16 changes: 9 additions & 7 deletions core/uwsgi.c
Original file line number Diff line number Diff line change
Expand Up @@ -1319,14 +1319,11 @@ void end_me(int signum) {
}

static void simple_goodbye_cruel_world(const char *reason) {

if (uwsgi.threads > 1 && !uwsgi_instance_is_dying) {
wait_for_threads();
}

int prev = uwsgi.workers[uwsgi.mywid].manage_next_request;
uwsgi.workers[uwsgi.mywid].manage_next_request = 0;
uwsgi_log("...The work of process %d is done (%s). Seeya!\n", getpid(), (reason != NULL ? reason : "no reason given"));
exit(0);
if (prev) { // Avoid showing same message from all threads.
uwsgi_log("...The work of process %d is done (%s). Seeya!\n", getpid(), (reason != NULL ? reason : "no reason given"));
}
}

void goodbye_cruel_world(const char *reason_fmt, ...) {
Expand Down Expand Up @@ -3721,6 +3718,11 @@ void uwsgi_ignition() {
}
}

// main thread waits other threads.
if (uwsgi.threads > 1) {
wait_for_threads();
}

// end of the process...
end_me(0);
}
Expand Down