Exemplo n.º 1
0
	process.nextTick(function() {
		if (data) p.write(data);
		pingable(p);
		socket.setNoDelay(true);
		pump(socket, p, socket, function() {
			p.destroy();
		});
	});
Exemplo n.º 2
0
Protocol.prototype.ping = function() {
	pingable(this._cable);
};
Exemplo n.º 3
0
var onpeer = function(peer) {
	pingable(peer);

	peer.on('add', function(id, opts, cb) {
		ps('add', {
			serviceName: id
		}, cb);
	});

	peer.on('remove', function(id, cb) {
		ps('remove', {
			serviceName: id
		}, cb);
	});

	peer.on('sync', function(id, service, cb) {
		ps('sync', {
			serviceName: id,
			fetchTar: path.join(__dirname, 'fetch-tar.js'),
			tarball: "http://localhost:7001/" + id
		}, cb);
	});

	peer.on('update', function(id, service, cb) { // do nothing right now
		cb();
	});

	peer.on('restart', function(id, cb) {
		ps('restart', {
			serviceName: id
		}, cb);
	});

	peer.on('start', function(id, cb) {
		ps('restart', {
			serviceName: id
		}, cb);
	});

	peer.on('stop', function(id, cb) {
		ps('stop', {
			serviceName: id
		}, cb);
	});

	peer.on('list', function(cb) {
		ps('list', {}, function(err, data) {
			if (err) {
				return cb(err, null);
			}
			return cb(null, [].concat(data || []));
		});
	});

	peer.on('ps', function(cb) {
		ps('ps', {}, function(err, data) {
			if (err) {
				return cb(err, null);
			}

			return cb(null, [{ id: origin, list: [].concat(data || [])}]);
		});
	});
};