简体   繁体   中英

PM2 port number express app

ecosystem.config.js

module.exports = {
  /**
   * Application configuration section
   * http://pm2.keymetrics.io/docs/usage/application-declaration/
   */
  apps : [

    // First application
    {
      name      : 'cms_stage',
      script    : 'www',
      env: {
        COMMON_VARIABLE: 'true',
        PORT: 3001,
        NODE_ENV: 'staging'
      }
    }
  ]
}

I have an express app when i start with PORT=3001 node www , it works. But with pm2 above config it doesn't. pm2 show started but it is not listening to 3001

I tried running PORT=3001 pm2 start cms_stage , pm2 start cms_stage and pm2 start ecosystem.config.js .

reading port number like this app.set('port', process.env.PORT || 3000) in app.js

在用pm2 kill杀死pm2之后工作了

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM