Skip to content

Node.js based forum software built for the modern web

fixed #2214 - each individual thread will create its own logrotate write handler, because if one is closed, everything crashes in a cascade effect because we're calling .write() after .end(), bleh.

Julian Lamb7ba6a0d8fa8
diff --git a/app.js b/app.js
index 8ed093631e..c0822a6edc 100644
--- a/app.js
+++ b/app.js
@@ -143,14 +143,10 @@ function start() {
plugins.ready(function() {
webserver.init(function() {
- // If this callback is called, this means that loader.js is used
- process.on('message', function(msg) {
- if (msg === 'bind') {
- webserver.listen();
- }
- });
- process.send({
- action: 'ready'
+ webserver.listen(function() {
+ process.send({
+ action: 'ready'
+ });
});
});
});
diff --git a/loader.js b/loader.js
index 0119f10f60..449d7e084f 100644
--- a/loader.js
+++ b/loader.js
@@ -28,6 +28,7 @@ Loader.init = function() {
exec: "app.js",
silent: silent
});
+ Loader.primaryWorker = 1;
if (silent) {
console.log = function(value) {
@@ -56,8 +57,6 @@ Loader.init = function() {
});
}
- worker.send('bind');
-
// Kill an instance in the shutdown queue
var workerToKill = Loader.shutdown_queue.pop();
if (workerToKill) {
@@ -162,9 +161,8 @@ Loader.init = function() {
};
Loader.start = function() {
- var worker;
-
- Loader.primaryWorker = 1;
+ var output = logrotate({ file: __dirname + '/logs/output.log', size: '1m', keep: 3, compress: true }),
+ worker;
for(var x=0;x<numCPUs;x++) {
// Only the first worker sets up templates/sounds/jobs/etc
diff --git a/src/webserver.js b/src/webserver.js
index d9d47d7f3c..518d0b9d14 100644
--- a/src/webserver.js
+++ b/src/webserver.js
@@ -129,7 +129,7 @@ if(nconf.get('ssl')) {
}
};
- module.exports.listen = function() {
+ module.exports.listen = function(callback) {
var bind_address = ((nconf.get('bind_address') === "0.0.0.0" || !nconf.get('bind_address')) ? '0.0.0.0' : nconf.get('bind_address')) + ':' + port;
winston.info('NodeBB attempting to listen on: ' + bind_address);
@@ -142,6 +142,10 @@ if(nconf.get('ssl')) {
primary: process.env.handle_jobs === 'true'
});
}
+
+ if (typeof callback === 'function') {
+ callback();
+ }
});
};