forgeplus-react/README.md

103 lines
2.4 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

####版本2024-6-20 更新版本包含开通工作台、代码库、issue、等模块的版本更新基本与forge一直属于内网版本邮件、协议签订等均已隐藏。
#### node版本
12.x/14.x
#### ng配置
后端服务另分配一个端口,不再映射域名
改为前端服务映射域名并转发到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;
...
}
```
#### 部署脚本
```bash
#!/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配置
```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 // 实例数
}]
}
```