Skip to content

Commit

Permalink
[fix] fix initial error
Browse files Browse the repository at this point in the history
  • Loading branch information
AndreasMadsen committed Mar 5, 2012
1 parent bdc2189 commit b1bb1bb
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 23 deletions.
4 changes: 2 additions & 2 deletions lib/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
var path = require('path');

//get the module root directory
exports.moduleRoot = path.join(path.dirname(module.filename), '/../../');
exports.moduleRoot = path.join(path.dirname(module.filename), '/../');

//shortcut to library
exports.libraryDir = path.join(exports.moduleRoot, '/lib/');
Expand All @@ -31,7 +31,7 @@

//lazy load proxy
exports.proxy = function (name) {
return require(path.join(exports.proxyDir, name + '.js'));
return path.join(exports.proxyDir, name + '.js');
};

//lazy load core
Expand Down
28 changes: 16 additions & 12 deletions lib/core/create.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@
(function () {
"use strict";

var path = require('path'),
immortal = require('immortal'),
var immortal = require('immortal'),

common = require('../common.js'),
inform = common.core('inform'),
Expand Down Expand Up @@ -45,14 +44,6 @@
*/
exports.startProxy = function (callback) {

// spawn proxy server as a unattached daemon
immortal.start(common.proxy('master'), {
strategy: 'daemon',
options: {
output: config.configuration.output
}
});

// continusely try to connect the proxy server
var timeout = 2200;
var tryConnect = function () {
Expand All @@ -78,8 +69,21 @@
});
};

// start continusely try connection
tryConnect();
// spawn proxy server as a unattached daemon
immortal.start(common.proxy('master'), {
strategy: 'development',
options: {
output: config.configuration.output
}
}, function (err) {
if (err) {
callback(err);
return;
}

// start continusely try connection
tryConnect();
});
};

})();
6 changes: 3 additions & 3 deletions lib/core/inform.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@
cb(error, exports.intercom);
};

// we will assume that ECONNREFUSED mean that the proxy server isn't open
// we will assume that ECONNREFUSED or ENOENT mean that the proxy server isn't open
var errorHandler = function (error) {
if (error.code === 'ECONNREFUSED') {
if (error.code === 'ECONNREFUSED' || error.code === 'ENOENT') {
callback(null);
return;
}
Expand All @@ -53,7 +53,7 @@
});

// connect to the TCP socket path
requester.connect('TCP', config.configuration.socket);
requester.connect('TCP', common.socketPath);
};

})();
3 changes: 3 additions & 0 deletions lib/helpers/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,5 +84,8 @@
//result holder
exports.configuration = false;
exports.protocols = [];

// should debug
exports.debug = false;

})();
11 changes: 8 additions & 3 deletions lib/module.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
cluster = require('cluster'),

common = require('./common.js'),
config = common.helpers('config'),
tracker = common.helpers('tracker'),
config = common.helper('config'),
tracker = common.helper('tracker'),
inform = common.core('inform'),
create = common.core('create'),

Expand All @@ -25,9 +25,14 @@
//create a object with "vhost" as its constructor name
vhost = module.exports = (function () {
function vhost() {}
util.inherts(vhost, events.EventEmitter);
util.inherits(vhost, events.EventEmitter);
return new vhost();
})();

vhost.debug = function (flag) {
config.debug = flag;
};

/**
* setup progress tracker
*/
Expand Down
6 changes: 3 additions & 3 deletions lib/proxy/master.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@
"use strict";

var cluster = require('cluster'),
thintalk = require('thinktalk'),
thintalk = require('thintalk'),
EventEmitter = require('events').EventEmitter,

common = require('../common'),
state = common.helpers('state');
state = common.helper('state');

// contain the current state;
var currentState = false;
Expand Down Expand Up @@ -106,7 +106,7 @@
listener.listen('TCP', common.socketPath);

// this wil read the state fill and emulate any RPC function
state.readState(function (method, json, callback) {
state.readState(common.statePath, function (method, json, callback) {
handlers[method].call({
callback: callback || function () {}
}, json);
Expand Down

0 comments on commit b1bb1bb

Please sign in to comment.