Skip to content

Commit

Permalink
Merge pull request #11 from AlexanderElias/master
Browse files Browse the repository at this point in the history
Add name field to monitor
  • Loading branch information
mafintosh committed Feb 24, 2016
2 parents d1bc197 + e886aff commit d3a9d8c
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ It is easy to use
var respawn = require('respawn')

var monitor = respawn(['node', 'server.js'], {
name: 'test', // set monitor name
env: {ENV_VAR:'test'}, // set env vars
cwd: '.', // set cwd
maxRestarts:10, // how many restarts are allowed within 60s
Expand Down
3 changes: 3 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ var Monitor = function(command, opts) {

this.status = 'stopped'
this.command = command
this.name = opts.name
this.cwd = opts.cwd || '.'
this.env = opts.env || {}
this.uid = opts.uid
Expand Down Expand Up @@ -185,6 +186,7 @@ Monitor.prototype.start = function() {
Monitor.prototype.toJSON = function() {
var doc = {
id: this.id,
name: this.name,
status: this.status,
started: this.started,
pid: this.pid,
Expand All @@ -195,6 +197,7 @@ Monitor.prototype.toJSON = function() {

if (!doc.id) delete doc.id
if (!doc.pid) delete doc.pid
if (!doc.name) delete doc.name
if (!doc.started) delete doc.started

return doc
Expand Down

0 comments on commit d3a9d8c

Please sign in to comment.