Node.js based forum software built for the modern web
merge
barisusakli1723894e5a99
diff --cc src/webserver.jsindex 5eeae83225,342e20f7ab..6d29ce2c4b--- a/src/webserver.js+++ b/src/webserver.js@@@ -31,51 -32,73 +31,51 @@@ if(nconf.get('ssl'))}(function (app) {- var port = nconf.get('PORT') || nconf.get('port');- "use strict";-+ var port = nconf.get('port');- logger.init(app);- emailer.registerApp(app);-- if (cluster.isWorker && process.env.handle_jobs === 'true') {- notifications.init();- user.startJobs();- }-- // Preparation dependent on plugins- plugins.ready(function() {- async.parallel([- async.apply(!nconf.get('from-file') ? meta.js.minify : meta.js.getFromFile, app.enabled('minification')),- async.apply(!nconf.get('from-file') ? meta.css.minify : meta.css.getFromFile),- async.apply(meta.sounds.init)- ]);- });+ module.exports.init = function() {+ emailer.registerApp(app);- async.parallel({- themesData: meta.themes.get,- currentThemeId: function(next) {- db.getObjectField('config', 'theme:id', next);- }- }, function(err, data) {- middleware = middleware(app, data);+ // Preparation dependent on plugins+ plugins.ready(function() {+ async.parallel([+ async.apply(!nconf.get('from-file') ? meta.js.minify : meta.js.getFromFile, app.enabled('minification')),+ async.apply(!nconf.get('from-file') ? meta.css.minify : meta.css.getFromFile),+ async.apply(meta.sounds.init)+ ]);+ });++ middleware = middleware(app);routes(app, middleware);- if (err) {- winston.error('Errors were encountered while attempting to initialise NodeBB.');- process.exit();- } else {- if (process.env.NODE_ENV === 'development') {- winston.info('Middlewares loaded.');- }+ // Cache static files on production+ if (global.env !== 'development') {+ app.enable('cache');+ app.enable('minification');++ // Configure cache-buster timestamp+ require('child_process').exec('git describe --tags', {+ cwd: path.join(__dirname, '../')+ }, function(err, stdOut) {+ if (!err) {+ meta.config['cache-buster'] = stdOut.trim();+ } else {+ fs.stat(path.join(__dirname, '../package.json'), function(err, stats) {+ meta.config['cache-buster'] = new Date(stats.mtime).getTime();+ });+ }+ });}- });-- // Cache static files on production- if (global.env !== 'development') {- app.enable('cache');- app.enable('minification');-- // Configure cache-buster timestamp- require('child_process').exec('git describe --tags', {- cwd: path.join(__dirname, '../')- }, function(err, stdOut) {- if (!err) {- meta.config['cache-buster'] = stdOut.trim();- } else {- fs.stat(path.join(__dirname, '../package.json'), function(err, stats) {- meta.config['cache-buster'] = new Date(stats.mtime).getTime();- });- }- });- }- if (port !== 80 && port !== 443 && nconf.get('use_port') === false) {- winston.info('Enabling \'trust proxy\'');- app.enable('trust proxy');- }+ if (port !== 80 && port !== 443 && nconf.get('use_port') === false) {+ winston.info('Enabling \'trust proxy\'');+ app.enable('trust proxy');+ }- if ((port === 80 || port === 443) && process.env.NODE_ENV !== 'development') {- winston.info('Using ports 80 and 443 is not recommend; use a proxy instead. See README.md');- }+ if ((port === 80 || port === 443) && process.env.NODE_ENV !== 'development') {+ winston.info('Using ports 80 and 443 is not recommend; use a proxy instead. See README.md');+ }+ };server.on('error', function(err) {winston.error(err.stack);