Permalink
Browse files

fix .stop

  • Loading branch information...
1 parent 6469af5 commit 7048302f9dbef213c6f4a85a14805d6ffece89c3 @substack committed Mar 1, 2012
Showing with 17 additions and 8 deletions.
  1. +16 −7 index.js
  2. +1 −1 package.json
View
@@ -209,6 +209,19 @@ Propagit.prototype.createService = function (remote, conn) {
});
};
+ service.stop = function (opts, cb) {
+ var drones = self.getDrones(opts)
+ var pending = drones.length;
+ if (pending === 0) return cb()
+
+ drones.forEach(function (drone) {
+ self.emit('stop', drone.id, opts);
+ drone.stop(opts.pid, function () {
+ if (--pending === 0) cb(null, drone.id);
+ });
+ });
+ };
+
service.register = function (role, obj) {
if (role === 'drone') {
self.drones.push(obj);
@@ -295,6 +308,7 @@ Propagit.prototype.drone = function (fn) {
else {
proc.status = 'stopped';
proc.process.kill();
+ delete self.processes[id];
cb();
}
};
@@ -389,18 +403,13 @@ Propagit.prototype.drone = function (fn) {
return self;
};
-Propagit.prototype.stop = function (opts, id, cb) {
+Propagit.prototype.stop = function (opts, cb) {
var self = this;
- if (typeof opts === 'string') {
- id = opts;
- opts = undefined;
- }
-
stream.readable = true;
(opts ? self.getDrones(opts) : self.drones).forEach(function (drone) {
- drone.stop(id, cb);
+ drone.stop(opts.pid, cb);
});
return self;
View
@@ -1,7 +1,7 @@
{
"name" : "propagit",
"description" : "cascading multi-server git deployment",
- "version" : "0.4.5",
+ "version" : "0.4.6",
"repository" : {
"type" : "git",
"url" : "git://github.com/substack/propagit.git"

0 comments on commit 7048302

Please sign in to comment.