Unitech/pm2 — pull request #273 by vwal (2014-01-30 00:16:29+00:00)
Title: Added the ability to accept JSON via a pipe from standard input.

Added the ability to pipe JSON in. This is useful specifically when using Fabric to manage remote servers running pm2, as this way the JSON which is already available for the control script can simply be piped in without having to transfer a separate JSON file to the remote. Used the UNIX-standard hyphen to indicate an stdinput stream. Does not interfere with other command line options. Now something like this is possible (e.g. in bash):

#!/bin/bash

read -d '' my_json <<_EOF_
[{
"name" : "app1",
"script" : "/home/projects/pm2_nodetest/app.js",
"instances" : "4",
"error_file" : "./logz/child-err.log",
"out_file" : "./logz/child-out.log",
"pid_file" : "./logz/child.pid",
"exec_mode" : "cluster_mode",
"port" : 4200
}]
_EOF_

echo $my_json | pm2 start -