Permalink
Browse files

Moved the isOpen function to the utilities module

  • Loading branch information...
1 parent 7f93697 commit 8fc09c1bfd4919768b76589609642fc9d56bd247 @MiguelMadero committed Oct 9, 2012
Showing with 1 addition and 26 deletions.
  1. +1 −26 lib/cluster/worker.js
View
@@ -1,7 +1,4 @@
var fs = require('fs')
- , net = require('net')
- , timeout = 400
- , sys = require("sys")
, utils = require('utilities')
, dispatch = require('./worker_dispatch')
, Logger = require('./worker_logger').Logger
@@ -79,7 +76,7 @@ Worker.prototype = new (function () {
, ssl = this.config.ssl ? ' (SSL)' : ''
, spdy = this.config.spdy ? '(SPDY)' : '';
- this.isOpen(port, hostname, function (isOpen) {
+ utils.network.isPortOpen(port, hostname, function (isOpen) {
if (isOpen) {
console.log("The port " + port + " is already in use.");
// TODO: abort
@@ -100,28 +97,6 @@ Worker.prototype = new (function () {
}
};
- this.isOpen = function (port, host, callback) {
- var isOpen = false;
- var conn = net.createConnection(port, host);
-
- var timeoutId = setTimeout(function() {onClose();}, timeout);
- var onClose = function() {
- clearTimeout(timeoutId);
- delete conn;
- callback(isOpen, port, host);
- };
-
- var onOpen = function() {
- isOpen = true;
- //console.log(host+":"+port+" is taken");
- conn.end();
- };
-
- conn.on('close', onClose);
- conn.on('error', function() {conn.end();});
- conn.on('connect', onOpen);
-}
-
this.configure = function (config) {
this.config = config;
this._afterConfigure();

0 comments on commit 8fc09c1

Please sign in to comment.