Skip to content

Commit

Permalink
fix the monitor
Browse files Browse the repository at this point in the history
  • Loading branch information
James Halliday committed Mar 7, 2012
1 parent 7654993 commit 8d1bdfa
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 10 deletions.
8 changes: 4 additions & 4 deletions bin/drone.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ drone.on('error', function (err) {
console.error(err && err.stack || err);
});

drone.on('spawn', function (id, opts) {
emit('spawn', id, opts);
drone.on('spawn', function (proc) {
emit('spawn', proc);
console.log(
'[' + opts.repo + '.' + opts.commit.slice(8) + '] '
+ opts.command.join(' ')
'[' + proc.repo + '.' + proc.commit.slice(8) + '] '
+ proc.command.join(' ')
);
});

Expand Down
34 changes: 28 additions & 6 deletions bin/monitor.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,36 @@ p.on('error', function (err) {

p.hub.on('up', function (hub) {
var em = new EventEmitter;
em.on('spawn', function (id, opts) {
console.dir([ 'spawn', id, opts ]);
em.on('spawn', function (proc) {
console.log(
'(spawned '
+ proc.drone + '#' + proc.id
+ ' : ' + proc.command.join(' ')
+ ')'
);
});

em.on('stdout', function (buf, opts) {
if (opts) {
console.dir([ 'stdout', buf, opts ]);
}
em.on('stdout', function (buf, proc) {
console.log(
'[' + proc.drone + '#' + proc.id + '] '
+ buf.replace(/\n$/, '')
);
});

em.on('stderr', function (buf, proc) {
console.log(
'[' + proc.drone + '#' + proc.id + '] '
+ buf.replace(/\n$/, '')
);
});

em.on('exit', function (code, sig, proc) {
console.log(
'(exited '
+ proc.drone + '#' + proc.id
+ ' : ' + proc.command.join(' ')
+ ')'
);
});

hub.subscribe(em.emit.bind(em));
Expand Down

0 comments on commit 8d1bdfa

Please sign in to comment.