zoukankan      html  css  js  c++  java
  • NGINX热部署

    备份二进制文件:

    cp /usr/bin/nginx nginx.old
    

    把编译好的新版Nginx的二进制文件覆盖旧版本。objs目录为编译过程中的中间文件目录。

    cp -r /new_nginx/objs/nginx /usr/bin/ -f 
    

    向正在运行Nginx的master进程发送热部署信号:

    ps -ef | grep nginx
    
    root       6668      1  0 19:50 ?        00:00:00 nginx: master process /usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
    www        6674   6668  0 19:50 ?        00:00:00 nginx: worker process
    www        6677   6668  0 19:50 ?        00:00:00 nginx: worker process
    root       9256   7671  0 20:49 pts/0    00:00:00 grep --color=auto nginx
    
    kill -USR2 6668
    

    Nginx将会建立一个新的master和多个worker进程,新的请求新的连接将会发送到新的nginx进程中。旧的nginx进程已不再使用。

    root       6668      1  0 19:50 ?        00:00:00 nginx: master process /usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
    www        6674   6668  0 19:50 ?        00:00:00 nginx: worker process
    www        6677   6668  0 19:50 ?        00:00:00 nginx: worker process
    root       9285   6668  0 21:00 ?        00:00:00 nginx: master process /usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
    www        9286   9285  7 21:00 ?        00:00:00 nginx: worker process
    www        9287   9285  7 21:00 ?        00:00:00 nginx: worker process
    root       9289   7671  0 21:00 pts/0    00:00:00 grep --color=auto nginx
    

    关闭旧Nginx进程,注意进程状态。

    kill -WINCH 6668
    
    root       6668      1  0 19:50 ?        00:00:00 nginx: master process /usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
    root       9285   6668  0 21:00 ?        00:00:00 nginx: master process /usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
    www        9286   9285  0 21:00 ?        00:00:00 nginx: worker process
    www        9287   9285  0 21:00 ?        00:00:00 nginx: worker process
    root       9305   7671  0 21:06 pts/0    00:00:00 grep --color=auto nginx
    

    旧的Nginx中worker进程已被销毁,而master进程还在。用于在新版本的Nginx中若遇到问题,可以重新reload旧版本的nginx进程拉起worker进程,用于保留版本回退,顾旧版本的Nginx主进程不会自动关闭。


    Nginx安装包解压后的根目录中有contrib目录,把contrib/vim下的所有文件复制到~/.vim目录下以使Nginx的配置文件代码高亮。

    cp -r contrib/vim/* ~/.vim/
  • 相关阅读:
    Canvas与Image互相转换示例以及利用该技术实现微信长按自动识别二维码功能
    chrome浏览器无法安装非应用商店插件的解决办法
    用canvas绘制android机器人
    TortoiseGit保存用户名和密码的方法
    event对象的兼容性
    利用jQuery无缝滚动插件liMarquee实现图片(链接)和文字(链接)向右无缝滚动(兼容ie7+)
    jQuery动画的hover连续触发动画bug处理
    用jquery实现平滑的页面滚动效果
    实现段落文字两端对齐的css样式
    前端构建工具gulpjs的使用介绍及技巧(转)
  • 原文地址:https://www.cnblogs.com/qiutianjia/p/11574063.html
Copyright © 2011-2022 走看看