Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function findAndStart() {
self._socket = nssocket.createServer(workerProtocol);
self._socket.on('listening', function () {
//
// `listening` listener doesn't take error as the first parameter
//
self.emit('start');
if (callback) {
callback(null, self._sockFile);
}
});
self._socket.on('error', function (err) {
if (err.code === 'EADDRINUSE') {
return findAndStart();
}
else if (callback) {
callback(err);
Node.prototype.start = function() {
if(this.listening) return
// Set up the server
this.server = nssocket.createServer(function (socket) {
this.logger.debug('Incoming Connection from '+socket.socket.remoteAddress+':'+socket.socket.remotePort)
socket.data(['smoke', 'handshake'], this.onHandshake.bind(this, socket))
socket.data(['smoke', 'peer request'], this.onUnconnectedPeerRequest.bind(this, socket))
socket.data(['smoke', 'pong'], this.onPong.bind(this, socket))
socket.on('error', function(er) {
this.logger.error(er)
socket.destroy()
}.bind(this))
socket._smokeTimeout = setTimeout(function() {
socket.destroy()
}, 5000)
}.bind(this))
constructor({ orchestrator, heartbeat, ready }) {
this.orchestrator = orchestrator;
if (heartbeat) {
this.stopLater = _.debounce(this._stop.bind(this), HUB_HEARTBEAT_TIMEOUT);
}
let that = this;
this._server = nssocket.createServer(async function(socket) {
log.info('Connection established from ember-cli');
// Docker does some weird stuff for containers with published ports
// before they start actually listening on the port. Long story short,
// we need a handshake when we first establish a connection.
socket.data('hand', function() {
socket.send('shake');
});
// Ember-cli may shut us down manually.
socket.data('shutdown', function() {
log.info('Received shutdown message from ember-cli');
orchestrator.stop();
});
if (heartbeat) {
function listenRev(cb) {
var listener_server = require('nssocket').createServer(function(_socket) {
});
listener_server.listen(4322, '0.0.0.0', function() {
console.log('Reverse interact online');
cb();
});
}
server.prototype.listen = function Listen(callback) {
var self = this;
this.connection = nssocket.createServer(function(socket) {
var onError = function OnError(e) {
socket._connected = false;
socket.destroy();
};
socket.on('error', onError);
socket._connected = true;
self.bindSocket(socket);
});
this.connection.on('error', function(e) {
self.emit('error', e);
});
self.connection.listen(self.config.port, self.config.host, function() {
if(typeof callback == 'function') callback.call(self);
});
return this;
};
function Seed() {
events.EventEmitter.call(this);
this.nodes = {};
this.sockets = {};
this.nsserver = nssocket.createServer(function (socket) {
var nodeId = uuid.v1();
var nodeInfo = {
id: nodeId
}
this.sockets[nodeId] = socket;
this.nodes[nodeId] = nodeInfo;
socket.send('id', nodeId);
socket.on('close', function (data) {
delete this.nodes[nodeId];
delete this.sockets[nodeId];
this.broadcast('node::offline', nodeId);
}.bind(this));
socket.on('error', function (err) {