Skip to content

Commit

Permalink
added crashes counter
Browse files Browse the repository at this point in the history
  • Loading branch information
xeaone committed May 4, 2016
1 parent 9038739 commit 6d928fc
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ var Monitor = function(command, opts) {
this.uid = opts.uid
this.gid = opts.gid
this.pid = 0
this.crashes = 0
this.stdio = opts.stdio
this.stdout = opts.stdout
this.stderr = opts.stderr
Expand Down Expand Up @@ -125,7 +126,7 @@ Monitor.prototype.start = function() {
child.stdout.on('data', function(data) {
self.emit('stdout', data)
})

if (self.stdout) {
child.stdout.pipe(self.stdout)
}
Expand All @@ -135,7 +136,7 @@ Monitor.prototype.start = function() {
child.stderr.on('data', function(data) {
self.emit('stderr', data)
})

if (self.stderr) {
child.stderr.pipe(self.stderr)
}
Expand Down Expand Up @@ -190,6 +191,7 @@ Monitor.prototype.toJSON = function() {
status: this.status,
started: this.started,
pid: this.pid,
crashes: this.crashes,
command: this.command,
cwd: this.cwd,
env: this.env
Expand All @@ -199,13 +201,15 @@ Monitor.prototype.toJSON = function() {
if (!doc.pid) delete doc.pid
if (!doc.name) delete doc.name
if (!doc.started) delete doc.started
if (!doc.crashes) delete doc.crashes

return doc
}

Monitor.prototype._crash = function() {
if (this.status !== 'running') return
this.status = 'crashed'
this.crashes = this.crashes++
this.emit('crash')
if (this.status === 'crashed') this._stopped()
}
Expand Down

0 comments on commit 6d928fc

Please sign in to comment.