Switch branches/tags
Nothing to show
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
66 lines (45 sloc) 1.24 KB
layout title description permalink
Process Actions
Trigger functions from CLI

Process Actions

By plugging process actions onto your code, you will be able to trigger them via the PM2 CLI.

First make sure you added the library pmx to your code:

npm install pmx --save

Then in your code:

var pmx = require('pmx');

pmx.action('hello', function(reply) {
  reply({ answer : 'world' });

setInterval(function() {
  // Keep application online
}, 100);

Start the application with PM2. To trigger process actions, use the command:

pm2 trigger <application-name> <action-name>

process actions

You can also list all available process actions:

pm2 show <application-name>

process actions

Passing a parameter

To pass a parameter to the remote function, just add the param attribute to the callback:

var pmx = require('pmx');

pmx.action('world', function(param, reply) {
  reply({success : param});

Restart your application and call this process function with PM2:

pm2 trigger <application-name> <action-name> [parameter]