Robert Mennell Robert Mennell - 7 days ago 6
Linux Question

PM2(node) Sending a message to a cluster from the commandline

So I have a process managed with

PM2
that's made in
Nodejs
which is pretty typical. However looking through documentation it looks like it's possible to send messages to process launched in cluster mode.

The problem is that the documentation is programmatic, with no hints on how to call that from the command line other than passing a
sigusr2
to the application. If I could pass a message with
sigusr2
that'd also solve my problem, but just passing a message to the cluster is useful enough if I could find that.

So is there a way to pass a message to a cluster of processes managed by
PM2
so I can handle it with the
process.on('message', ()=>{})
construct?

Answer

This feature will be available on PM2 2.1.6!

https://github.com/Unitech/pm2/issues/2509

Official documentation: http://pm2.keymetrics.io/docs/usage/process-actions/