pm2 - Is there a way to restrict some code for master only?

Viewed 162

I'm trying to use pm2 to deploy my nodejs application.

I have some cron jobs that should get executed only once. With PM2 cluster mode, I'm able to scale my application across multiple CPUs, but all of them will execute my cron jobs.

Just like the nodejs API has cluster.isMaster or cluster.isWorker, is there a way I can ask only the PM2 master to execute it?

0 Answers
Related