Question

how to run pm2 in app plattforms using nodejs api

Posted August 9, 2021 74 views
Node.jsAPIDigitalOcean App Platform

I have a simple nodejs API to test on the app platform. To keep it running I’m using pm2 and works as expected on localhost. Currently, I’m using something like “pm2 start build/index.js” to start it. After building and deploying I’m getting the below error:

https://ibb.co/gFBzZMp
https://ibb.co/yd0cQzV

Now, I was reading about use pm2-runtime instead of pm2 but I don’t know how can use it on the app platform. Does anybody know how can keep alive my API REST using pm2?

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

×
Submit an Answer
1 answer

Hello,

First Give the below command as the Build Command in your App settings

npm install pm2 -g

and then you can try the below command as your Run time command.

pm2-runtime start index.js