removed node cluster spawn procs on ports

This commit is contained in:
barisusakli
2014-12-03 14:03:41 -05:00
parent 3ad3e781f3
commit 64e13df14c
8 changed files with 139 additions and 238 deletions

View File

@@ -7,7 +7,6 @@ var winston = require('winston'),
less = require('less'),
crypto = require('crypto'),
async = require('async'),
cluster = require('cluster'),
plugins = require('../plugins'),
emitter = require('../emitter'),
@@ -22,7 +21,7 @@ module.exports = function(Meta) {
Meta.css.defaultBranding = {};
Meta.css.minify = function(callback) {
if (!cluster.isWorker || process.env.cluster_setup === 'true') {
if (nconf.get('isPrimary') === 'true') {
winston.verbose('[meta/css] Minifying LESS/CSS');
db.getObjectFields('config', ['theme:type', 'theme:id'], function(err, themeData) {
var themeId = (themeData['theme:id'] || 'nodebb-theme-vanilla'),
@@ -64,7 +63,7 @@ module.exports = function(Meta) {
}
], function(err, minified) {
// Propagate to other workers
if (cluster.isWorker) {
if (process.send) {
process.send({
action: 'css-propagate',
cache: minified[0],
@@ -81,7 +80,7 @@ module.exports = function(Meta) {
});
});
} else {
winston.verbose('[meta/css] Cluster worker ' + cluster.worker.id + ' skipping LESS/CSS compilation');
winston.verbose('[meta/css] Cluster worker ' + process.pid + ' skipping LESS/CSS compilation');
if (typeof callback === 'function') {
callback();
}
@@ -106,7 +105,7 @@ module.exports = function(Meta) {
acpCachePath = path.join(__dirname, '../../public/admin.css');
fs.exists(cachePath, function(exists) {
if (exists) {
if (!cluster.isWorker || process.env.cluster_setup === 'true') {
if (nconf.get('isPrimary') === 'true') {
winston.verbose('[meta/css] (Experimental) Reading stylesheets from file');
async.map([cachePath, acpCachePath], fs.readFile, function(err, files) {
Meta.css.cache = files[0];
@@ -125,7 +124,7 @@ module.exports = function(Meta) {
});
};
function minify(source, paths, destination, callback) {
function minify(source, paths, destination, callback) {
less.render(source, {
paths: paths,
compress: true
@@ -149,7 +148,7 @@ module.exports = function(Meta) {
}
// Save the compiled CSS in public/ so things like nginx can serve it
if (!cluster.isWorker || process.env.cluster_setup === 'true') {
if (nconf.get('isPrimary') === 'true') {
Meta.css.commitToFile(destination);
}