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

Why discard requests in listen queue while worker gracefully kill? #2693

Open
NightmareRevisited opened this issue Nov 15, 2024 · 0 comments

Comments

@NightmareRevisited
Copy link

NightmareRevisited commented Nov 15, 2024

void gracefully_kill(int signum) {

	uwsgi_log("Gracefully killing worker %d (pid: %d)...\n", uwsgi.mywid, uwsgi.mypid);
	uwsgi.workers[uwsgi.mywid].manage_next_request = 0;

	if (uwsgi.threads > 1) {
		// Stop event_queue_wait() in other threads.
		// We use loop_stop_pipe only in threaded workers to avoid
		// unintensional behavior changes in single threaded workers.
		int fd;
		if ((fd = uwsgi.loop_stop_pipe[1]) > 0) {
			close(fd);
			uwsgi.loop_stop_pipe[1] = 0;
		}
		return;
	}

	// still not found a way to gracefully reload in async mode
	if (uwsgi.async > 0) {
		if (uwsgi.workers[uwsgi.mywid].shutdown_sockets)
			uwsgi_shutdown_all_sockets();
		exit(UWSGI_RELOAD_CODE);
	}

	if (!uwsgi.workers[uwsgi.mywid].cores[0].in_request) {
		if (uwsgi.workers[uwsgi.mywid].shutdown_sockets)
			uwsgi_shutdown_all_sockets();
		exit(UWSGI_RELOAD_CODE);
	}
}

uwsgi.workers[uwsgi.mywid].manage_next_request = 0; make worker not to deal with request in queue.While all workers exit, those requests left in listen queue are all discarded,and this will lead to nginx 502 error.What is the reason for this design?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant