Permalink
Browse files

fix stop to take multiple pids at once and fix some formatting

  • Loading branch information...
1 parent 8d1bdfa commit 043e815b704dd1f850f32c60e3bae8ae469400ac @substack committed Mar 7, 2012
Showing with 53 additions and 30 deletions.
  1. +5 −5 README.markdown
  2. +27 −14 bin/drone.js
  3. +9 −0 bin/monitor.js
  4. +5 −6 bin/spawn.js
  5. +5 −3 bin/stop.js
  6. +2 −2 package.json
View
@@ -114,15 +114,15 @@ You can control which drone by specifying `--drone=id`.
Your spawned process will get the $REPO name, $COMMIT hash, $DRONE_ID, and
$PROCESS_ID as environment variables from propagit.
-fleet stop id
---------------
+fleet stop id0 [id1, id2...]
+----------------------------
-Stop a process. Get the `id` by running `fleet ps`. It doesn't matter which
+Stop processes. Get each `id` by running `fleet ps`. It doesn't matter which
drone the process is running on, fleet spams the request out to all the drones
and ignores the request if the drone doesn't have the requested process id.
fleet monitor
-------------
-Work in progress. This command will let you listen to all the events ever across
-the whole cluster.
+Show all spawn, exit, stdout, and stderr events happening everywhere across all
+of the drones.
View
@@ -15,36 +15,49 @@ drone.on('error', function (err) {
console.error(err && err.stack || err);
});
+drone.on('deploy', function (deploy) {
+ emit('deploy', deploy);
+ console.log(
+ '(deployed '
+ + deploy.repo + '/' + deploy.commit.slice(8)
+ + ')'
+ );
+});
+
drone.on('spawn', function (proc) {
emit('spawn', proc);
console.log(
- '[' + proc.repo + '.' + proc.commit.slice(8) + '] '
- + proc.command.join(' ')
+ '(spawned ' + proc.id + '#' + proc.repo + '.' + proc.commit.slice(8)
+ + ' : ' + proc.command.join(' ') + ')'
);
});
drone.on('exit', function (code, sig, opts) {
emit('exit', code, sig, opts);
- console.error([
- '[' + opts.repo + '.' + opts.commit.slice(8) + ']',
- opts.command.join(' '),
- 'exited with code', code,
- 'from', sig,
- ].join(' '));
+ console.error(
+ '(exited '
+ + opts.id + '#' + opts.repo + '.' + opts.commit.slice(8)
+ + ' with code ' + code
+ + ' from signal ' + sig
+ + ': ' + opts.command.join(' ')
+ + ')'
+ );
});
drone.on('stdout', function (buf, opts) {
emit('stdout', buf.toString(), opts);
- console.log('['
- + opts.repo + '.' + opts.commit.slice(8)
- + '] ' + buf);
+ console.log(
+ '[' + opts.id + '#' + opts.repo + '.' + opts.commit.slice(8)
+ + '] ' + buf.toString().replace(/\n$/, '')
+ );
});
drone.on('stderr', function (buf, opts) {
emit('stderr', buf.toString(), opts);
- console.log('['
- + opts.repo + '.' + opts.commit.slice(8)
- + '] ' + buf);
+ console.log(
+ '[' + opts.id + '#' + opts.repo + '.' + opts.commit.slice(8)
+ + '] ' + buf.toString().replace(/\n$/, '')
+ );
});
drone.on('up', function () {
View
@@ -10,6 +10,15 @@ p.on('error', function (err) {
p.hub.on('up', function (hub) {
var em = new EventEmitter;
+
+ em.on('deploy', function (deploy) {
+ console.log(
+ '(deployed '
+ + deploy.drone + '#' + deploy.repo + '/' + deploy.commit
+ + ')'
+ );
+ });
+
em.on('spawn', function (proc) {
console.log(
'(spawned '
View
@@ -35,12 +35,11 @@ p.hub(function (hub) {
});
function spawn (hub, opts) {
- hub.spawn(opts, function (err, id) {
- console.log(
- '[' + id + '] '
- + 'spawned ' + opts.repo + '/' + opts.commit
- + ': ' + opts.command.join(' ')
- );
+ hub.spawn(opts, function (err, procs) {
+ Object.keys(procs).forEach(function (droneId) {
+ var id = procs[droneId];
+ console.log('(spawned ' + droneId + '#' + id + ')');
+ });
p.hub.close();
});
}
View
@@ -17,10 +17,12 @@ p.hub(function (hub) {
var opts = {
drone : argv.drone,
drones : argv.drones,
- pid : argv._[0].replace(/^pid#/, ''),
+ pid : argv._.map(function (x) { return x.replace(/^pid#/, '') }),
};
- hub.stop(opts, function (drone) {
- console.log('[' + drone + '] stopped ' + opts.pid);
+ hub.stop(opts, function (err, drones) {
+ Object.keys(drones).forEach(function (id) {
+ console.log('[' + id + '] stopped ' + drones[id].join(' '));
+ });
p.hub.close();
});
});
View
@@ -1,7 +1,7 @@
{
"name" : "fleet",
"description" : "command a cluster of processes ",
- "version" : "0.0.2",
+ "version" : "0.0.3",
"repository" : {
"type" : "git",
"url" : "git://github.com/substack/fleet.git"
@@ -33,7 +33,7 @@
"test" : "tap test/*.js"
},
"dependencies" : {
- "propagit" : "~0.5.0",
+ "propagit" : "~0.5.3",
"optimist" : "~0.3.1",
"mkdirp" : "~0.3.0"
},

0 comments on commit 043e815

Please sign in to comment.