package
process monitor command
npm install psyGitHub-flavored package documentation.
Across all versions.
Download trend unavailable.
Runtime metadata.
Tagged topics.
psy keeps restarting a process when it crashes. It never stops.
This package is like pm2 or forever, but fewer features so there are less things that can go wrong and fewer options to configure.
Just install psy to get started:
$ npm install -g psyNow you can start a process called static:
$ psy start -n static -- ecstatic ./public -p 8080and another process called api:
$ psy start -n api -- node server.jswe can list the running processes:
$ psy ls
static running 5914 less than a minute ago ecstatic ./public -p 8080
api running 5932 less than a minute ago node server.jsrestart a process:
$ psy restart static
$ psy ls
static running 6015 less than a minute ago ecstatic ./public -p 8080
api running 5932 2 minutes ago node server.jsstop a process:
$ psy stop api
$ psy ls
static running 6015 less than a minute ago ecstatic ./public -p 8080
api stopped --- --- node server.jsstop and remove a process:
$ psy rm static
$ psy ls
api stopped --- --- node server.jslog lifecycle events and stdout+stderr:
$ psy log msgs
!!! PROCESS SPAWN: PID 12086
!!! PROCESS START
2015-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 12092
2015-05-18T14:09:29.264Z
2015-05-18T14:09:30.303Z
2015-05-18T14:09:31.314Z
!!! PROCESS EXIT: SIGTERM
!!! PROCESS STOPrestart a process on reboot, add the following to your crontab:
@reboot psy daemonand SEVERAL more!
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 processes
psy rm NAME
psy remove NAME
Stop a process and remove it from the list.
psy list
psy ls
List the running processes as text columns.
--json Print the data as json instead of text columns.
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_PATHstatefile: PSY_STATEFILEsockfile: PSY_SOCKFILEpidfile: PSY_PIDFILErpcfile: path to rpc serverdebug: 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.
Used in:
MIT
yoshuawuyts
javascript@yosh.is
Estimated unpacked size across 33 packages.
1.0 MB
Includes dependencies.
^0.6.5
5.0.12
^2.1.1
2.1.2
^1.0.0
1.0.0
^0.2.0
0.2.0
^1.0.9
4.3.1
^2.1.3
2.6.0
^2.0.0
5.1.0
^1.1.0
1.4.5
^1.0.1
1.1.0