Restart tunnel if all jobs have restarted.

This commit is contained in:
John-David Dalton
2014-05-03 21:41:02 -07:00
parent 3de50e8dd4
commit c19f87134e

View File

@@ -624,6 +624,7 @@ function Tunnel(properties) {
}, this); }, this);
var completed = 0, var completed = 0,
restarted = [],
success = true, success = true,
total = all.length, total = all.length,
tunnel = this; tunnel = this;
@@ -641,9 +642,20 @@ function Tunnel(properties) {
tunnel.dequeue(); tunnel.dequeue();
}); });
_.invoke(all, 'on', 'restart', function() {
if (!_.contains(restarted, this)) {
restarted.push(this);
}
// restart tunnel if all jobs have restarted
if (_.isEmpty(_.difference(all, restarted))) {
tunnel.restart();
}
});
this.on('stop', function() { this.on('stop', function() {
completed = 0; completed = 0;
success = true; success = true;
restarted.length = 0;
_.invoke(all, 'reset'); _.invoke(all, 'reset');
}); });