Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Start multiple processes via npm scripts using PM2

Tags:

node.js

npm

pm2

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?

like image 814
Andrey Radkevich Avatar asked Apr 23 '26 16:04

Andrey Radkevich


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
like image 120
sdgluck Avatar answered Apr 26 '26 06:04

sdgluck



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!