$ psy log msgs!!! PROCESS SPAWN: PID 12086!!! PROCESS START2015-05-18T14:09:26.886Z/home/substack/projects/psy/msgs.js:3 if (Math.random() < 0.2) (undefined).whatever() ^TypeError: Cannot read property 'whatever' of undefined at null._repeat (/home/substack/projects/psy/msgs.js:3:41) at wrapper [as _onTimeout] (timers.js:267:19) at Timer.listOnTimeout (timers.js:89:15)!!! PROCESS EXIT: 1!!! PROCESS SLEEP!!! PROCESS SPAWN: PID 120922015-05-18T14:09:29.264Z2015-05-18T14:09:30.303Z2015-05-18T14:09:31.314Z!!! PROCESS EXIT: SIGTERM!!! PROCESS STOP
restart a process on reboot, add the following to your crontab:
@reboot psy daemon
and SEVERAL more!
usage
psy start {OPTIONS} -- [COMMAND...] Start a process COMMAND. -n, --name Set a NAME for the process. --cwd Current working directory for COMMAND --env.NAME=VALUE Set environment variables explicitly for COMMAND. --sleep Sleep MS milliseconds between restarts. Default: 1000 --maxRestarts Number of restarts allowed in 60 seconds before stopping. -1 for Infinity. Default: -1. -l, --logfile Write stdout, stderr, and process lifecycle events to FILE. If NAME isn't given, the generated hex name will be printed. When the process crashes, it will be restarted unless maxRestarts is reached.psy stop NAME Stop a process by its NAME.psy restart NAME Restart a process by its NAME. --all Restart all processespsy rm NAMEpsy remove NAME Stop a process and remove it from the list.psy listpsy ls List the running processes as text columns. --json Print the data as json instead of text columns.
javascript api
The JavaScript API will respect the same environment variables as the cli. You can provide overrides in the opts objects, however. See cmd.js for an example.
psy(opts)
Constructor.
var psy = require('psy')(opts)
opts:
psypath: PSY_PATH
statefile: PSY_STATEFILE
sockfile: PSY_SOCKFILE
pidfile: PSY_PIDFILE
rpcfile: path to rpc server
debug: boolean to debug.
psy.server(cb)
Starts a psy server, does not close it.
psy.server(argv, function (err, r, c) { if (err) error(err) else c.end()})
psy.restart(name, cb)
psy.restart(name, function (err) { if (err) throw err})
psy.stop(name, cb)
psy.remove(name, cb)
psy.log(name, cb)
returns callback with cb(err, stream)
psy.kill(cb)
psy.close(cb)
psy.list(cb)
return callback with cb(err, items)
psy.run(cb)
Run a daemon.
cb: runs autod under the hood and returns the same callback.