[英]How can I deploy only one specific nodeJS app to one specific environment with PM2?
I have two nodejs app deployed on Digital Ocean, with PM2, which I am learning.我在 Digital Ocean 上部署了两个 nodejs 应用程序,我正在学习 PM2。 I'd like to know how I could update my apps (services) separately.我想知道如何单独更新我的应用程序(服务)。
At the moment my pm2 config looks like this:目前我的 pm2 配置如下所示:
// ecosystem.config.js
module.exports = {
apps: [
{
name: `app1`,
script: './app1.js',
// ...
},
{
name: `app2`,
script: './app2.js',
// ...
}
],
deploy: {
production: {
key: '',
user: 'admin',
host: '',
ref: '',
repo: '',
path: '/home/admin/app/prod',
'post-deploy': './deploy.sh production'
},
development: {
key: '',
user: 'admin',
host: '',
ref: '',
repo: '',
path: '/home/admin/app/development',
'post-deploy': './deploy.sh development'
},
}
}
I can deploy per environment, like pm2 deploy production
.我可以按环境部署,例如pm2 deploy production
。
But, can I do something like pm2 deploy development app2
to only update app2?但是,我可以像pm2 deploy development app2
只更新 app2 吗?
You have many ways to do that, for me I always create ecosystem file in the client folder and server folder, then create publish ecosystem file in the root folder, like:你有很多方法可以做到这一点,对我来说,我总是在客户端文件夹和服务器文件夹中创建生态系统文件,然后在根文件夹中创建发布生态系统文件,例如:
The root ecosystem file like:根生态系统文件如:
deploy: {
frontend: {
...other,
path: '/app/easyv_spaceship',
'post-deploy': 'cd ./client && npm install && npm run build'
},
backend: {
...other,
path: '/app/easyv_spaceship',
'post-deploy': 'cd ./server && npm install && npm run tsc && pm2 startOrRestart ecosystem.config.js --env production'
}
}
hope this can inspire you.希望这能激励你。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.