零停机时间nginx动态重新加载用于蓝/绿部署

零停机时间nginx动态重新加载用于蓝/绿部署,nginx,blue-green-deployment,Nginx,Blue Green Deployment,在蓝绿色部署管道的上下文中,当前使用以下nginx template.conf模板文件: http { server { listen 8080; location / { proxy_pass http://0.0.0.0:{{ api_port }}; } } } 在部署新版本的API时,通过用新端口值替换{{API_port}生成新的nginx.conf。端口值在6000和6001之间交替 6000

在蓝绿色部署管道的上下文中,当前使用以下
nginx template.conf
模板文件:

http {
    server {
        listen 8080;

        location / {
            proxy_pass http://0.0.0.0:{{ api_port }};
        }
    }
}
在部署新版本的API时,通过用新端口值替换
{{API_port}
生成新的
nginx.conf
。端口值在
6000
6001
之间交替

6000  ---->  (deploy) 6001  ---->  (deploy) 6000  ---->  (deploy) 6001  ---->  ...
生成新的
nginx.conf
文件后,旧的
nginx
进程将停止并启动一个新进程:

sudo nginx-s quit-c nginx-old.conf
sudo nginx-c nginx-new.conf
这项工作正常,但需要半秒钟的停机时间,在此期间无法处理新请求

为了消除停机时间,我尝试重新加载nginx:

sudo nginx-s reload-c nginx-new.conf
但是由于某些原因,这不会应用新配置,
nginx
仍然使用旧配置运行,就好像没有执行任何
reload
一样

  • 有没有一种方法可以在不停机的情况下重新加载考虑了新配置的nginx
  • 或者,是否有可能通过不同的方法达到预期的结果