Go to file
Eeeros 73754d777f Merge pull request '同步到测试分支' (#780) from pre_gitlink_ssr into gitlink_ssr_head
1
2024-11-06 10:15:20 +08:00
.idea href 2021-03-29 17:14:56 +08:00
.vscode 服务新建成功提示语+激 活devops后未跳转到引擎配置 2022-05-26 14:51:48 +08:00
config C:/Program Files/Git/react 2024-09-13 17:34:50 +08:00
public 合并代码 2024-10-30 15:37:31 +08:00
scripts 优化版 2020-04-28 17:23:34 +08:00
server 添加keywords字段 2024-06-27 16:12:34 +08:00
src Merge pull request 'uos专区' (#779) from gitlink_management into pre_gitlink_ssr 2024-10-31 09:28:23 +08:00
.babelrc cont. 2023-12-29 16:43:14 +08:00
.bashrc 专区数据集 2024-04-15 08:52:12 +08:00
.gitignore test 2023-12-26 13:49:10 +08:00
LICENSE ADD MulanPSL-2.0 LICENSE 2021-10-22 09:55:53 +08:00
README.md 静态文件在ng中处理 2024-04-23 18:38:01 +08:00
Routes.js cont. 2024-08-29 14:07:48 +08:00
add.txt 优化版 2020-04-28 17:23:34 +08:00
package.json 优化代码、恢复图片放大功能 2024-05-11 10:25:13 +08:00
pm2.json 更新相关配置与文档 2024-04-23 16:21:05 +08:00
readme.txt first commit 2020-03-16 14:12:11 +08:00

README.md

gitlink-ssr版本

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; 
      ...
    }

部署脚本

#!/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 // 实例数
  }]
}