Can pm2 run an 'npm start' script

前端 未结 17 1151
心在旅途
心在旅途 2020-12-04 04:45

Is there a way for pm2 to run an npm start script or do you just have to run pm2 start app.js

So in development

npm start

相关标签:
17条回答
  • 2020-12-04 05:04

    See to enable clustering:

    pm2 start npm --name "AppName" -i 0 -- run start
    

    What do you think?

    0 讨论(0)
  • 2020-12-04 05:07

    Unfortunately, it seems that pm2 doesn't support the exact functionality you requested https://github.com/Unitech/PM2/issues/1317.

    The alternative proposed is to use a ecosystem.json file Getting started with deployment which could include setups for production and dev environments. However, this is still using npm start to bootstrap your app.

    0 讨论(0)
  • 2020-12-04 05:09

    Yes. Use pm2 start npm --no-automation --name {app name} -- run {script name}. It works. The --no-automation flag is there because without it PM2 will not restart your app when it crashes.

    0 讨论(0)
  • 2020-12-04 05:09

    Yes we can, now pm2 support npm start, --name to species app name.

    pm2 start npm --name "app" -- start
    
    0 讨论(0)
  • 2020-12-04 05:10
    pm2 start ./bin/www
    

    can running

    if you wanna multiple server deploy you can do that. instead of pm2 start npm -- start

    0 讨论(0)
  • 2020-12-04 05:10

    Now, You can use after:

    pm2 start npm -- start
    

    Follow by https://github.com/Unitech/pm2/issues/1317#issuecomment-220955319

    0 讨论(0)
提交回复
热议问题