跳到主要内容
版本:1.2.0

服务部署

准备目标服务器,并确保服务器上安装了Node.js(Node版本推荐>=16.x)、pm2、nginx。

部署

复制应用程序代码

将xiaoiu-survey应用程序代码复制到目标服务器上,一般使用git clone将代码同步到服务器。

启动服务端

cd xiaoju-survey/server

npm install

npm run build

npm run start:prod

或者

cd xiaoju-survey/server

npm install

npm run build

pm2 -n xiaoju-survey start npm -- run start:prod

启动前端

🌀NOTE:nginx服务的安装流程为:nginx安装指南文档

以下为最小化可运行配置,具体请根据各公司要求进行完善:

server {
listen 8080;
server_name localhost;

# gzip config
root xiaoju-survey/web/dist;

location / {
rewrite ^/$ /management last;
}

location /render {
try_files $uri $uri/ /render/index.html;
}

location ~ ^/render/(.*) {
rewrite ^/render/(.*) /render.html last;
}

location /management {
try_files $uri $uri/ /management/index.html;
}

location ~ ^/management/(.*) {
rewrite ^/management/(.*) /management.html last;
}

location ^~ /api {
proxy_pass http://127.0.0.1:3000;
}
}

监控

使用适当的日志和监控工具来监视xiaoju-survey应用程序的运行状态。这将有助于您及时发现并解决潜在问题。

举例:

如果我们要监控服务的内存或CPU等基础指标,我们可以建立在k8s中,并安装k8s的dashboard,dashboard的安装和介绍指南地址:

如果我们要监控内存泄漏监控线上故障,由于我们是使用Node.js作为服务引擎,所以可以接入alinode或easy-monitor: