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

Update nginx reload 热升级原理.txt #8

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all 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
14 changes: 7 additions & 7 deletions nginx-1.9.2/nginx reload 热升级原理.txt
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
/*
quit���̣��������յ�quit�źţ�Ȼ����quit�źŸ�worker���̣�worker�����յ���
close listen�ļ���fd��Ȼ��ȴ����е����Ӵ�����ϣ��ӽ����˳�
quit过程:主进程收到quit信号,然后发送quit信号给worker进程,worker进程收到后
close listen的监听fd,然后等待已有的连接处理完毕,子进程退出

reload���̣�master�����յ�reload�źţ������¼��������ļ���ͬʱ�����µ�worker
���̣�Ȼ����quit�źŵ�ԭ����worker�ӽ��̣�Դworker�ӽ��̾ͻ�ܾ�bind
���ܿͻ�������,ȫ�����µ�worker�������������ӡ�
reload过程,master进程收到reload信号,则重新加载配置文件,同时创建新的worker
进程,然后发送quit信号到原来的worker子进程,原worker子进程就会拒绝bind
接受客户端连接,全部由新的worker进程来接收连接。

����������:����ͨ��kill����SIGUSR2(NGX_CHANGEBIN_SIGNAL)�źŸ�Դmaster���̣��ý����յ����źź󣬰Ѹý���bind������fdȫ�����õ�NGINX
���������У�Ȼ��ͨ��fork+execve�����û���������Ч��Ȼ�������µ�nginx���̣������µ�nginx���̾Ϳ��Ի�ȡ��֮ǰmaster bind��fd��
热升级过程:首先通过kill发送SIGUSR2(NGX_CHANGEBIN_SIGNAL)信号给源master进程,该进程收到该信号后,把该进程bind监听的fd全部设置到NGINX
环境变量中,然后通过fork+execve来设置环境变量生效。然后重启新的nginx进程,这样新的nginx进程就可以获取到之前master bind的fd。
*/