[英]How to specify app version in pm2 start via Yarn?
I have a Node.js + Express application, let's call myapp v0.3.0
, that I start with Yarn scripts , such as:我有一个 Node.js + Express 应用程序,我们称之为myapp v0.3.0
,我从Yarn 脚本开始,例如:
yarn prod
I've deployed my production application with PM2 , using:我已经使用PM2部署了我的生产应用程序,使用:
pm2 start yarn --name myapp -- prod
This works and the app is properly deployed, but when I look at pm2 list
, the version of the PM2 application is Yarn's version (0.39.1), not myapp
's version (0.3.0):这可行并且应用程序已正确部署,但是当我查看pm2 list
时,PM2 应用程序的版本是Yarn 的版本(0.39.1),而不是myapp
的版本(0.3.0):
┌────┬───────┬───────────┬─────────┬──────┬────────┬────────┬───┬────────┬─────┬────────┬──────┬──────────┐
│ id │ name │ namespace │ version │ mode │ pid │ uptime │ ↺ │ status │ cpu │ mem │ user │ watching │
├────┼───────┼───────────┼─────────┼──────┼────────┼────────┼───┼────────┼─────┼────────┼──────┼──────────┤
│ 1 │ myapp │ default │ 0.39.1 │ fork │ 124777 │ 43h │ 1 │ online │ 0% │ 49.2mb │ pm2 │ disabled │
└────┴───────┴───────────┴─────────┴──────┴────────┴────────┴───┴────────┴─────┴────────┴──────┴──────────┘
My CI/CD tool uses the version
field from PM2 to manage automatic deployments.我的 CI/CD 工具使用 PM2 中的version
字段来管理自动部署。 Is there a way to make the version track the application version (eg 0.3.0) instead of Yarn's version?有没有办法让版本跟踪应用程序版本(例如 0.3.0)而不是 Yarn 的版本?
Add yarnwrapper bash script in the same directory of your package.json:在 package.json 的同一目录中添加 yarnwrapper bash 脚本:
#!/bin/bash
eval "/${HOME}/.nvm/versions/node/$(node -v)/bin/yarn prod"
Launch it with pm2:使用 pm2 启动它:
pm2 start yarnwrapper --name myapp --interpreter bash
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.