Start multiple processes via npm scripts using PM2

Viewed 975

I want to start multiple processes by pm2.

I found how to start one process for npm run start:

pm2 start npm -- start

But when I've tried make something like pm2 start npm -- event for npm run event it doesn't start a new process but restarts the first one.

How can I start multiple process by npm and pm2?

1 Answers

Use the --name flag to give each processes a unique name for PM2 to identify them by.

For example:

pm2 start --name=start npm -- start
pm2 start --name=event npm -- run event

Further operations should use the name you have given each process. For example to stop them:

pm2 stop start
pm2 stop event
Related