How could I integrate pm2 into parse server?


Just would like to know if there is any potential conflict or side effect (such as causing session issues, etc) for such integration?

If it is totally OK, how should I do? Just follow the standard PM2 steps (PM2 - Quick Start) ? Great thanks.

Yes. Parse Server is essentially an Express.js middleware and usually run on a regular Express.js app. So using pm2 to launch Parse Server shouldn’t be a problem.

1 Like

You’ll need to configure pm2 to ignore the logs file, I normally use something such as:

    "name"        : "AppName",
    "script"      : "npm run start",
    "ignore_watch": ["logs", "node_modules"],
    "watch"       : true,
    "merge_logs"  : true,
    "cwd"         : "/home/ubuntu/backend",

@dblythy Does this mean the logs generated by pm2 will be NOT generated any more, and only parse server logs ?

No, pm2 logs will still be generated. This configuration just stops pm2 restarting when Parse Server logs

1 Like

I’ve also started using the cluster mode. What this means is that PM2 will automatically run multiple instances of your application. You can do this by simply adding the following to the ecosystem.config.js file (note that I’m using the max number of CPUs, but you could trim this down to suite):

instances: "max",
exec_mode: "cluster",

One little note on using this feature. I’ve found that one cannot login to the Parse Admin dashboard when this feature is being used. I’m sure there is some config that could help with this, but I’ve not taken the time to figure it out. To get around this, I stop the additional instances that are running, login and then restart the instances I’ve just stopped.

If anyone knows how to get around that, please feel free to share :smiley: