Why is PM2 not launching my Node process?

前端 未结 3 1852
佛祖请我去吃肉
佛祖请我去吃肉 2021-01-05 00:55

Previously I have had success implementing PM2, but not currently.

My node app does run just fine if I start it manually, but nothing I do gets it to run

3条回答
  •  抹茶落季
    2021-01-05 01:38

    Just a note for those who are saying to run this in no-daemon mode, (pm2 start --no-daemon), you should use this mode if you're trying to diagnose the reason why when you run with the daemon, your script fails.

    Almost invariably, this is because you're telling PM2 to watch a dist folder or similar while it's building, so PM2 keeps restarting until it hits its limit (because files are being regenerated at pretty rapid speed) and then outputs the "errored" status.

    Running in no-daemon is absolutely not recommended in production. Ensure that PM2 is running as a daemon so it can itself restart, and so it can restart your processes as a process itself. If you kill your terminal sessions or they are automatically timed out on your host, you will quickly find your service dies when that happens.

    So, in short.. do it the right way and figure out what the problem is, rather than being lazy and turning PM2 into a glorified wrapper for the node binary.

提交回复
热议问题