Debug application which is run using pm2

You’re almost there, use node_args instead of args: args are your script arguments node_args are arguments that are passed to node executable { “name”: “myName”, “script”: “app.js”, “node_args”: [“–debug=7000”] } PM2 json schema. If someone still has problems with the debug setting after this, in some case you have to disable the cluster mode for … Read more

How to specify a port number for pm2

You can use an environment variable. For example: NODE_PORT=3002 pm2 start -i 0 app.js Here is how to read the value in app: console.log(process.env.NODE_PORT); Or, if you are building an Express app: PORT=3002 pm2 start -i 0 ./bin/www Express loads PORT automatically when the application starts.

How to make a task job with PM2?

Use the –cron option: -c –cron <cron_pattern> For example: pm2 start sendMail.js –cron “*/15 * * * *” Pm2 will now restart the sendMail.js script on the hour, and at 15, 30 and 45 minutes past the hour

What is the purpose of “pm2 save”?

pm2 save takes a snapshot of your currently running Node applications. You can then restore these applications using pm2 resurrect. This is useful because it means you don’t have to manually restart each application when you restart pm2 (such as a machine reboot). Instead, you can just have a script that calls pm2 resurrect and … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)