Appearance
阿里云云效自动化部署nodejs项目
具体就不多介绍了,可以去看阿里云云效自动化部署vue项目这篇文章
流水线源
构建
执行命令
npm install
npm install
构建物上传
主机部署
我的这个nodejs服务是部署在二级域名中的。我用的是宝塔中的nodejs版本管理器,不是pm2
部署脚本
sh
tar zxvf /www/wwwroot/docs.suntemple.cn/node_cicd/package.tgz -C /www/wwwroot/docs.suntemple.cn/node_cicd/
#删除dist压缩包
rm -rf /www/wwwroot/docs.suntemple.cn/node_cicd/package.tgz
#重启服务
sh /www/wwwroot/docs.suntemple.cn/node_cicd/deploy.sh restart
tar zxvf /www/wwwroot/docs.suntemple.cn/node_cicd/package.tgz -C /www/wwwroot/docs.suntemple.cn/node_cicd/
#删除dist压缩包
rm -rf /www/wwwroot/docs.suntemple.cn/node_cicd/package.tgz
#重启服务
sh /www/wwwroot/docs.suntemple.cn/node_cicd/deploy.sh restart
这里最主要的是重启服务,我用了一个脚本文件deploy.sh
deploy.sh
文件。这个文件需要权限才能启动
sh
#!/bin/bash
# 设置脚本在出错时立即退出
set -e
# 6. 启动新服务
nodemon index.js
#!/bin/bash
# 设置脚本在出错时立即退出
set -e
# 6. 启动新服务
nodemon index.js
开启权限
sh
chmod +x deploy.sh
chmod +x deploy.sh