修改流水线:deploy-api.yml
12.x/14.x
后端服务另分配一个端口,不再映射域名 改为前端服务映射域名,并转发到3000
server { listen 8080; server_name testforgeplus.trustie.net; location / { root /home/pdl/forgeplus/public/; autoindex off; try_files $uri @backend; } location @backend { proxy_pass http://127.0.0.1:3000; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto $scheme; } } server { listen 8081; # server_name testforgeplus.trustie.net; # return http://$server_name$request_uri; # rewrite ^(.*)$ https://$host$1 permanent; ... }
#!/bin/bash set -x # Avoid root execution if [ `id|sed -e s/uid=//g -e s/\(.*//g` -eq 0 ]; then echo "Execution by root not allowed" exit 1 fi cd #上线分支 Branch=pre_gitlink_ssr #代码路径 Code_Path=/home/pdl/forgeplus/public/react/forgeplus-react #Build代码路径 Build_Path=/home/pdl/forgeplus/public/react cd $Code_Path pwd git checkout $Branch git pull # 分别打静态包与node服务包 npm install npm run build npm run build:server # 复制一份到原来build路径 #cd $Build_Path #rm -rf build.bak #mv build build.bak #scp -r $Code_Path/build ./ pm2 restart pm2.json # 重新加载 Nginx 配置 /home/pdl/nginx/sbin/nginx -s reload # 检查 Nginx 是否重启成功 if [ "$?" -eq "0" ]; then echo -e "\e[1;42m restart nginx OK! \e[0m" else echo -e "\e[1;31m restart nginx FAILED! \e[0m" fi
pm2.json配置
{ "apps": [{ "name": "gitlink-ssr", "script": "buildserver/bundle.js", "watch": false, "log_date_format": "YYYY-MM-DD HH:mm Z", "exec_mode": "cluster", "max_memory_restart": "300M", // 内存超过300m重启 "env": { "NODE_ENV": "production", "PORT": "8081" // 修改为ng给后端服务另配的端口 }, "instances": 4 // 实例数 }] }
版权所有:中国计算机学会技术支持:开源发展技术委员会 京ICP备13000930号-9 京公网安备 11010802047560号
版本:2024-6-20 更新版本,包含开通工作台、代码库、issue、等模块的版本更新,基本与forge一直,属于内网版本,邮件、协议签订等均已隐藏。
node版本
12.x/14.x
ng配置
后端服务另分配一个端口,不再映射域名 改为前端服务映射域名,并转发到3000
部署脚本
pm2.json配置