curl -sL https://rpm.nodesource.com/setup_12.x | sudo bash -
sudo yum install -y nodejs
npm install pm2 -g
下载项目的源代码
cd /data/build
svn checkout SVN路径
/sbin/iptables -I INPUT -p tcp --dport 3000 -j ACCEPT
service iptables save
cd /data
pm2 ecosystem
vi ecosystem.config.js
module.exports = {
apps : [
{
name: ‘appApi‘,
script: ‘/data/build/Node.js/appApi/bin/www‘,
watch: [‘/data/build/Node.js/appApi/‘],
instances: 4,
env: {
‘profile‘: ‘production‘
}
}
]
};
pm2 delete all
pm2 start ecosystem.config.js
pm2 save
more ~/.pm2/dump.pm2
pm2 startup
修改源代码后,只要更新源代码即可,pm2会监控变化自动更新
在CentOS上部署Node.js项目(用pm2)