nginx 配置无感换jar包

nginx.conf 主配置文件配置详情

user nobody;
worker_processes 2;
events {
    worker_connections  10240;
}

http {
    include       mime.types;
    default_type  application/octet-stream;
    sendfile        on;
    keepalive_timeout  65;
    #include nginx1.conf;
    include nginx-other.conf;
    include /home/zqcn/zh.conf;
    server {
        listen       8081;
        server_name  localhost;

      
       # location ~/group([0-9])/M00 {
        #    ngx_fastdfs_module;
       # }

        error_page 500 502 503 504 /50x.html;
        location = /50x.html {
            root   html;
        }   
    }
}

nginx1.conf

server {
        listen       8666;
        server_name   0.0.0.0 localhost;
        client_body_buffer_size 20m;
        client_max_body_size 1024m;

        proxy_buffer_size 512k;
        proxy_buffers 4 512k;
        proxy_busy_buffers_size 512k;
        proxy_temp_file_write_size 512k;
        proxy_connect_timeout       600;
        proxy_send_timeout          600;
        proxy_read_timeout          600;

		//反向代理java服务
        location /clue {
            # add_header 'Access-Control-Allow-0rigin' '*' ;
            proxy_pass http://localhost:9001/clue;
            #proxy_pass http://localhost:9004/clue_other;
        }
		//测试环境
        location /clue-test {
            # add_header 'Access-Control-Allow-0rigin' '*' ;
            proxy_pass http://localhost:9002/clue-test;
        }
        //动静分离
        location /clue-web-test {
            alias /iflytek/chark/clue/test/web/dist;
        }
        location /clue-web {
            alias /iflytek/chark/clue/web/dist;
        }
     	//管理端页面
        location /clue-admin {
           alias /iflytek/chark/clue/admin/dist;
        }
}

nginx-other.conf

server {
        listen       8666;
        server_name   0.0.0.0 localhost;
        client_body_buffer_size 20m;
        client_max_body_size 1024m;

        proxy_buffer_size 512k;
        proxy_buffers 4 512k;
        proxy_busy_buffers_size 512k;
        proxy_temp_file_write_size 512k;
        proxy_connect_timeout       600;
        proxy_send_timeout          600;
        proxy_read_timeout          600;

     	location /clue-test {
            # add_header 'Access-Control-Allow-0rigin' '*' ;
            proxy_pass http://localhost:9002/clue-test;
        }
        //生产环境-动态切换此配置
        location /clue {
            # add_header 'Access-Control-Allow-0rigin' '*' ;
            #proxy_pass http://localhost:9001/clue;
            proxy_pass http://localhost:9004/clue_other;
        }
        //动静分离
        location /clue-web-test {
            alias /iflytek/chark/clue/test/web/dist;
        }
        location /clue-web {
            alias /iflytek/chark/clue/web/dist;
        }
     	//管理端页面
        location /clue-admin {
           alias /iflytek/chark/clue/admin/dist;
        }
}

配置文件结束后需要编写两个环境的jar包启动脚本
start.sh

#!/bin/bash

nohup java -jar business-clue.jar --spring.profiles.active=prod >> clue.log 2>&1 &  
# 启动jar 沉睡60S 再切换配置文件
sleep 60 && cd /iflytek/chark/nginx/nginx/conf
# 替换
sed -i "s/include chark-other.conf;/#include nginx-other.conf;/" nginx.conf
# 替换后重启
sed -i "s/#include chark.conf;/include nginx1.conf;/" nginx.conf && ./../sbin/nginx -s reload

tailf /iflytek/chark/clue/java/clue.log

other_start.sh

#!/bin/bash

nohup java -jar business-clue-other.jar --spring.profiles.active=other >> clue-other.log 2>&1  &


sleep 60 && cd /iflytek/chark/nginx/nginx/conf


sed -i "s/include chark.conf;/#include chark.conf;/" nginx.conf 
sed -i "s/#include chark-other.conf;/include chark-other.conf;/" nginx.conf && ./../sbin/nginx -s reload


 tail -f /iflytek/chark/clue/java/clue-other.log

结束!

  • 2
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值