| 
									
										
										
										
											2014-12-02 17:40:48 -05:00
										 |  |  | 'use strict'; | 
					
						
							| 
									
										
										
										
											2014-02-27 10:06:31 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-02-17 20:20:42 -07:00
										 |  |  | var	nconf = require('nconf'); | 
					
						
							|  |  |  | var fs = require('fs'); | 
					
						
							|  |  |  | var url = require('url'); | 
					
						
							|  |  |  | var path = require('path'); | 
					
						
							|  |  |  | var fork = require('child_process').fork; | 
					
						
							|  |  |  | var async = require('async'); | 
					
						
							|  |  |  | var logrotate = require('logrotate-stream'); | 
					
						
							|  |  |  | var file = require('./src/file'); | 
					
						
							|  |  |  | var pkg = require('./package.json'); | 
					
						
							| 
									
										
										
										
											2014-10-17 01:47:13 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-05-06 21:41:04 -04:00
										 |  |  | nconf.argv().env().file({ | 
					
						
							| 
									
										
										
										
											2017-02-17 19:31:21 -07:00
										 |  |  | 	file: path.join(__dirname, '/config.json'), | 
					
						
							| 
									
										
										
										
											2015-05-06 21:41:04 -04:00
										 |  |  | }); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-02-17 20:20:42 -07:00
										 |  |  | var	pidFilePath = __dirname + '/pidfile'; | 
					
						
							|  |  |  | var output = logrotate({ file: __dirname + '/logs/output.log', size: '1m', keep: 3, compress: true }); | 
					
						
							|  |  |  | var silent = nconf.get('silent') === 'false' ? false : nconf.get('silent') !== false; | 
					
						
							|  |  |  | var numProcs; | 
					
						
							|  |  |  | var workers = []; | 
					
						
							|  |  |  | var Loader = { | 
					
						
							|  |  |  | 	timesStarted: 0, | 
					
						
							|  |  |  | }; | 
					
						
							| 
									
										
										
										
											2014-02-27 10:06:31 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-10-13 11:43:39 +02:00
										 |  |  | Loader.init = function (callback) { | 
					
						
							| 
									
										
										
										
											2014-09-30 21:48:39 -04:00
										 |  |  | 	if (silent) { | 
					
						
							| 
									
										
										
										
											2016-10-13 11:43:39 +02:00
										 |  |  | 		console.log = function () { | 
					
						
							| 
									
										
										
										
											2016-03-31 12:26:51 -04:00
										 |  |  | 			var args = Array.prototype.slice.call(arguments); | 
					
						
							|  |  |  | 			output.write(args.join(' ') + '\n'); | 
					
						
							| 
									
										
										
										
											2014-09-30 21:48:39 -04:00
										 |  |  | 		}; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-10-17 01:47:13 -04:00
										 |  |  | 	process.on('SIGHUP', Loader.restart); | 
					
						
							| 
									
										
										
										
											2014-11-04 17:39:13 -05:00
										 |  |  | 	process.on('SIGUSR2', Loader.reload); | 
					
						
							| 
									
										
										
										
											2014-11-17 14:47:36 -05:00
										 |  |  | 	process.on('SIGTERM', Loader.stop); | 
					
						
							| 
									
										
										
										
											2014-10-17 01:47:13 -04:00
										 |  |  | 	callback(); | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-10-13 11:43:39 +02:00
										 |  |  | Loader.displayStartupMessages = function (callback) { | 
					
						
							| 
									
										
										
										
											2014-10-22 13:47:05 -04:00
										 |  |  | 	console.log(''); | 
					
						
							| 
									
										
										
										
											2014-10-17 01:47:13 -04:00
										 |  |  | 	console.log('NodeBB v' + pkg.version + ' Copyright (C) 2013-2014 NodeBB Inc.'); | 
					
						
							|  |  |  | 	console.log('This program comes with ABSOLUTELY NO WARRANTY.'); | 
					
						
							|  |  |  | 	console.log('This is free software, and you are welcome to redistribute it under certain conditions.'); | 
					
						
							|  |  |  | 	console.log('For the full license, please visit: http://www.gnu.org/copyleft/gpl.html'); | 
					
						
							|  |  |  | 	console.log(''); | 
					
						
							|  |  |  | 	callback(); | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-10-13 11:43:39 +02:00
										 |  |  | Loader.addWorkerEvents = function (worker) { | 
					
						
							|  |  |  | 	worker.on('exit', function (code, signal) { | 
					
						
							| 
									
										
										
										
											2014-09-03 15:23:40 -04:00
										 |  |  | 		if (code !== 0) { | 
					
						
							| 
									
										
										
										
											2016-10-13 11:42:29 +02:00
										 |  |  | 			if (Loader.timesStarted < numProcs * 3) { | 
					
						
							| 
									
										
										
										
											2017-02-18 01:12:18 -07:00
										 |  |  | 				Loader.timesStarted += 1; | 
					
						
							| 
									
										
										
										
											2014-09-04 00:01:08 -04:00
										 |  |  | 				if (Loader.crashTimer) { | 
					
						
							|  |  |  | 					clearTimeout(Loader.crashTimer); | 
					
						
							|  |  |  | 				} | 
					
						
							| 
									
										
										
										
											2016-10-13 11:43:39 +02:00
										 |  |  | 				Loader.crashTimer = setTimeout(function () { | 
					
						
							| 
									
										
										
										
											2014-09-04 00:01:08 -04:00
										 |  |  | 					Loader.timesStarted = 0; | 
					
						
							| 
									
										
										
										
											2014-12-03 23:16:50 -05:00
										 |  |  | 				}, 10000); | 
					
						
							| 
									
										
										
										
											2014-09-03 15:23:40 -04:00
										 |  |  | 			} else { | 
					
						
							| 
									
										
										
										
											2017-02-18 01:51:11 -07:00
										 |  |  | 				console.log((numProcs * 3) + ' restarts in 10 seconds, most likely an error on startup. Halting.'); | 
					
						
							| 
									
										
										
										
											2014-09-03 15:23:40 -04:00
										 |  |  | 				process.exit(); | 
					
						
							| 
									
										
										
										
											2014-09-03 01:24:26 -04:00
										 |  |  | 			} | 
					
						
							|  |  |  | 		} | 
					
						
							| 
									
										
										
										
											2014-09-03 15:23:40 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-10-13 11:42:29 +02:00
										 |  |  | 		console.log('[cluster] Child Process (' + worker.pid + ') has exited (code: ' + code + ', signal: ' + signal + ')'); | 
					
						
							| 
									
										
										
										
											2014-12-10 18:52:38 -05:00
										 |  |  | 		if (!(worker.suicide || code === 0)) { | 
					
						
							| 
									
										
										
										
											2014-12-03 14:17:05 -05:00
										 |  |  | 			console.log('[cluster] Spinning up another process...'); | 
					
						
							| 
									
										
										
										
											2014-09-05 13:44:56 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-11-17 12:56:00 +03:00
										 |  |  | 			forkWorker(worker.index, worker.isPrimary); | 
					
						
							| 
									
										
										
										
											2014-09-04 17:09:57 -04:00
										 |  |  | 		} | 
					
						
							| 
									
										
										
										
											2014-05-04 16:46:09 -04:00
										 |  |  | 	}); | 
					
						
							| 
									
										
										
										
											2014-09-04 00:56:50 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-10-13 11:43:39 +02:00
										 |  |  | 	worker.on('message', function (message) { | 
					
						
							| 
									
										
										
										
											2014-12-03 14:03:41 -05:00
										 |  |  | 		if (message && typeof message === 'object' && message.action) { | 
					
						
							|  |  |  | 			switch (message.action) { | 
					
						
							| 
									
										
										
										
											2017-02-18 02:38:03 -07:00
										 |  |  | 			case 'restart': | 
					
						
							|  |  |  | 				console.log('[cluster] Restarting...'); | 
					
						
							|  |  |  | 				Loader.restart(); | 
					
						
							| 
									
										
										
										
											2014-12-03 14:03:41 -05:00
										 |  |  | 				break; | 
					
						
							| 
									
										
										
										
											2017-02-18 02:38:03 -07:00
										 |  |  | 			case 'reload': | 
					
						
							|  |  |  | 				console.log('[cluster] Reloading...'); | 
					
						
							|  |  |  | 				Loader.reload(); | 
					
						
							| 
									
										
										
										
											2014-12-03 14:03:41 -05:00
										 |  |  | 				break; | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 	}); | 
					
						
							| 
									
										
										
										
											2014-10-28 16:33:14 -04:00
										 |  |  | }; | 
					
						
							| 
									
										
										
										
											2014-09-03 15:23:40 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-10-13 11:43:39 +02:00
										 |  |  | Loader.start = function (callback) { | 
					
						
							| 
									
										
										
										
											2014-12-03 15:46:52 -05:00
										 |  |  | 	numProcs = getPorts().length; | 
					
						
							| 
									
										
										
										
											2014-10-17 01:47:13 -04:00
										 |  |  | 	console.log('Clustering enabled: Spinning up ' + numProcs + ' process(es).\n'); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-02-18 01:12:18 -07:00
										 |  |  | 	for (var x = 0; x < numProcs; x += 1) { | 
					
						
							| 
									
										
										
										
											2016-11-17 12:56:00 +03:00
										 |  |  | 		forkWorker(x, x === 0); | 
					
						
							| 
									
										
										
										
											2014-09-04 17:09:57 -04:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2014-10-17 01:47:13 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-10-28 16:33:14 -04:00
										 |  |  | 	if (callback) { | 
					
						
							|  |  |  | 		callback(); | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2014-10-08 12:07:33 -04:00
										 |  |  | }; | 
					
						
							| 
									
										
										
										
											2014-09-03 15:23:40 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-11-17 12:56:00 +03:00
										 |  |  | function forkWorker(index, isPrimary) { | 
					
						
							| 
									
										
										
										
											2014-12-03 15:46:52 -05:00
										 |  |  | 	var ports = getPorts(); | 
					
						
							| 
									
										
										
										
											2016-11-16 12:20:44 -05:00
										 |  |  | 	var args = []; | 
					
						
							| 
									
										
										
										
											2014-12-03 15:46:52 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-02-18 01:52:56 -07:00
										 |  |  | 	if (!ports[index]) { | 
					
						
							| 
									
										
										
										
											2014-12-03 15:46:52 -05:00
										 |  |  | 		return console.log('[cluster] invalid port for worker : ' + index + ' ports: ' + ports.length); | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2014-11-27 14:09:01 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-12-03 17:10:25 -05:00
										 |  |  | 	process.env.isPrimary = isPrimary; | 
					
						
							| 
									
										
										
										
											2016-05-24 10:42:56 -04:00
										 |  |  | 	process.env.isCluster = ports.length > 1 ? true : false; | 
					
						
							| 
									
										
										
										
											2014-12-03 17:10:25 -05:00
										 |  |  | 	process.env.port = ports[index]; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-11-16 12:20:44 -05:00
										 |  |  | 	var worker = fork('app.js', args, { | 
					
						
							| 
									
										
										
										
											2014-12-03 14:03:41 -05:00
										 |  |  | 		silent: silent, | 
					
						
							| 
									
										
										
										
											2017-02-17 19:31:21 -07:00
										 |  |  | 		env: process.env, | 
					
						
							| 
									
										
										
										
											2014-12-03 14:03:41 -05:00
										 |  |  | 	}); | 
					
						
							| 
									
										
										
										
											2014-11-27 14:09:01 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-12-03 14:03:41 -05:00
										 |  |  | 	worker.index = index; | 
					
						
							|  |  |  | 	worker.isPrimary = isPrimary; | 
					
						
							| 
									
										
										
										
											2014-11-27 14:09:01 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-12-03 14:03:41 -05:00
										 |  |  | 	workers[index] = worker; | 
					
						
							| 
									
										
										
										
											2014-10-28 16:33:14 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-12-03 14:03:41 -05:00
										 |  |  | 	Loader.addWorkerEvents(worker); | 
					
						
							| 
									
										
										
										
											2014-11-26 17:24:49 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-12-03 14:03:41 -05:00
										 |  |  | 	if (silent) { | 
					
						
							| 
									
										
										
										
											2014-12-03 17:06:19 -05:00
										 |  |  | 		var output = logrotate({ file: __dirname + '/logs/output.log', size: '1m', keep: 3, compress: true }); | 
					
						
							| 
									
										
										
										
											2014-12-03 14:03:41 -05:00
										 |  |  | 		worker.stdout.pipe(output); | 
					
						
							|  |  |  | 		worker.stderr.pipe(output); | 
					
						
							| 
									
										
										
										
											2014-11-26 17:24:49 -05:00
										 |  |  | 	} | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-12-03 15:46:52 -05:00
										 |  |  | function getPorts() { | 
					
						
							| 
									
										
										
										
											2015-04-27 22:51:44 -04:00
										 |  |  | 	var _url = nconf.get('url'); | 
					
						
							|  |  |  | 	if (!_url) { | 
					
						
							| 
									
										
										
										
											2015-04-27 21:42:04 -04:00
										 |  |  | 		console.log('[cluster] url is undefined, please check your config.json'); | 
					
						
							|  |  |  | 		process.exit(); | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2015-04-27 22:51:44 -04:00
										 |  |  | 	var urlObject = url.parse(_url); | 
					
						
							| 
									
										
										
										
											2014-12-03 15:46:52 -05:00
										 |  |  | 	var port = nconf.get('port') || nconf.get('PORT') || urlObject.port || 4567; | 
					
						
							|  |  |  | 	if (!Array.isArray(port)) { | 
					
						
							|  |  |  | 		port = [port]; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	return port; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-10-13 11:43:39 +02:00
										 |  |  | Loader.restart = function () { | 
					
						
							| 
									
										
										
										
											2014-12-02 16:49:49 -05:00
										 |  |  | 	killWorkers(); | 
					
						
							| 
									
										
										
										
											2017-01-26 14:16:19 +03:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	var pathToConfig = path.join(__dirname, '/config.json'); | 
					
						
							| 
									
										
										
										
											2016-08-16 20:11:03 +03:00
										 |  |  | 	nconf.remove('file'); | 
					
						
							| 
									
										
										
										
											2017-01-26 14:16:19 +03:00
										 |  |  | 	nconf.use('file', { file: pathToConfig }); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-01-26 14:22:52 +03:00
										 |  |  | 	fs.readFile(pathToConfig, {encoding: 'utf-8'}, function (err, configFile) { | 
					
						
							| 
									
										
										
										
											2017-01-26 14:16:19 +03:00
										 |  |  | 		if (err) { | 
					
						
							|  |  |  | 			console.log('Error reading config : ' + err.message); | 
					
						
							|  |  |  | 			process.exit(); | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		var conf = JSON.parse(configFile); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		nconf.stores.env.readOnly = false; | 
					
						
							|  |  |  | 		nconf.set('url', conf.url); | 
					
						
							|  |  |  | 		nconf.stores.env.readOnly = true; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		Loader.start(); | 
					
						
							|  |  |  | 	}); | 
					
						
							| 
									
										
										
										
											2014-09-04 17:09:57 -04:00
										 |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-10-13 11:43:39 +02:00
										 |  |  | Loader.reload = function () { | 
					
						
							|  |  |  | 	workers.forEach(function (worker) { | 
					
						
							| 
									
										
										
										
											2014-12-03 14:03:41 -05:00
										 |  |  | 		worker.send({ | 
					
						
							| 
									
										
										
										
											2017-02-17 19:31:21 -07:00
										 |  |  | 			action: 'reload', | 
					
						
							| 
									
										
										
										
											2014-09-04 17:39:53 -04:00
										 |  |  | 		}); | 
					
						
							| 
									
										
										
										
											2014-09-04 17:09:57 -04:00
										 |  |  | 	}); | 
					
						
							| 
									
										
										
										
											2014-09-04 17:41:00 -04:00
										 |  |  | }; | 
					
						
							| 
									
										
										
										
											2014-09-03 15:23:40 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-10-13 11:43:39 +02:00
										 |  |  | Loader.stop = function () { | 
					
						
							| 
									
										
										
										
											2014-12-02 16:49:49 -05:00
										 |  |  | 	killWorkers(); | 
					
						
							| 
									
										
										
										
											2014-11-17 14:47:36 -05:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	// Clean up the pidfile
 | 
					
						
							|  |  |  | 	fs.unlinkSync(__dirname + '/pidfile'); | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-12-02 16:49:49 -05:00
										 |  |  | function killWorkers() { | 
					
						
							| 
									
										
										
										
											2016-10-13 11:43:39 +02:00
										 |  |  | 	workers.forEach(function (worker) { | 
					
						
							| 
									
										
										
										
											2014-12-03 14:03:41 -05:00
										 |  |  | 		worker.suicide = true; | 
					
						
							|  |  |  | 		worker.kill(); | 
					
						
							| 
									
										
										
										
											2014-12-02 16:49:49 -05:00
										 |  |  | 	}); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-10-13 11:43:39 +02:00
										 |  |  | Loader.notifyWorkers = function (msg, worker_pid) { | 
					
						
							| 
									
										
										
										
											2014-12-03 14:03:41 -05:00
										 |  |  | 	worker_pid = parseInt(worker_pid, 10); | 
					
						
							| 
									
										
										
										
											2016-10-13 11:43:39 +02:00
										 |  |  | 	workers.forEach(function (worker) { | 
					
						
							| 
									
										
										
										
											2014-12-03 14:03:41 -05:00
										 |  |  | 		if (parseInt(worker.pid, 10) !== worker_pid) { | 
					
						
							| 
									
										
										
										
											2014-12-10 19:44:27 -05:00
										 |  |  | 			try { | 
					
						
							|  |  |  | 				worker.send(msg); | 
					
						
							|  |  |  | 			} catch (e) { | 
					
						
							|  |  |  | 				console.log('[cluster/notifyWorkers] Failed to reach pid ' + worker_pid); | 
					
						
							|  |  |  | 			} | 
					
						
							| 
									
										
										
										
											2014-12-02 17:40:48 -05:00
										 |  |  | 		} | 
					
						
							| 
									
										
										
										
											2014-10-17 01:47:13 -04:00
										 |  |  | 	}); | 
					
						
							| 
									
										
										
										
											2014-10-28 16:33:14 -04:00
										 |  |  | }; | 
					
						
							| 
									
										
										
										
											2014-09-16 11:17:57 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-10-13 11:43:39 +02:00
										 |  |  | fs.open(path.join(__dirname, 'config.json'), 'r', function (err) { | 
					
						
							| 
									
										
										
										
											2015-04-27 22:41:44 -04:00
										 |  |  | 	if (!err) { | 
					
						
							| 
									
										
										
										
											2015-05-20 09:57:04 -04:00
										 |  |  | 		if (nconf.get('daemon') !== 'false' && nconf.get('daemon') !== false) { | 
					
						
							| 
									
										
										
										
											2015-09-29 18:22:41 -04:00
										 |  |  | 			if (file.existsSync(pidFilePath)) { | 
					
						
							| 
									
										
										
										
											2015-04-27 22:41:44 -04:00
										 |  |  | 				try { | 
					
						
							|  |  |  | 					var	pid = fs.readFileSync(pidFilePath, { encoding: 'utf-8' }); | 
					
						
							|  |  |  | 					process.kill(pid, 0); | 
					
						
							|  |  |  | 					process.exit(); | 
					
						
							|  |  |  | 				} catch (e) { | 
					
						
							|  |  |  | 					fs.unlinkSync(pidFilePath); | 
					
						
							|  |  |  | 				} | 
					
						
							|  |  |  | 			} | 
					
						
							| 
									
										
										
										
											2014-09-04 17:48:22 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-04-27 22:41:44 -04:00
										 |  |  | 			require('daemon')({ | 
					
						
							|  |  |  | 				stdout: process.stdout, | 
					
						
							| 
									
										
										
										
											2017-02-17 19:31:21 -07:00
										 |  |  | 				stderr: process.stderr, | 
					
						
							| 
									
										
										
										
											2015-04-27 22:41:44 -04:00
										 |  |  | 			}); | 
					
						
							| 
									
										
										
										
											2014-09-04 17:48:22 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-04-27 22:41:44 -04:00
										 |  |  | 			fs.writeFile(__dirname + '/pidfile', process.pid); | 
					
						
							|  |  |  | 		} | 
					
						
							| 
									
										
										
										
											2014-09-04 17:48:22 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-04-27 22:41:44 -04:00
										 |  |  | 		async.series([ | 
					
						
							|  |  |  | 			Loader.init, | 
					
						
							|  |  |  | 			Loader.displayStartupMessages, | 
					
						
							| 
									
										
										
										
											2017-02-17 19:31:21 -07:00
										 |  |  | 			Loader.start, | 
					
						
							| 
									
										
										
										
											2016-10-13 11:43:39 +02:00
										 |  |  | 		], function (err) { | 
					
						
							| 
									
										
										
										
											2015-04-27 22:41:44 -04:00
										 |  |  | 			if (err) { | 
					
						
							|  |  |  | 				console.log('[loader] Error during startup: ' + err.message); | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 		}); | 
					
						
							|  |  |  | 	} else { | 
					
						
							|  |  |  | 		// No config detected, kickstart web installer
 | 
					
						
							|  |  |  | 		var child = require('child_process').fork('app'); | 
					
						
							| 
									
										
										
										
											2014-10-17 01:47:13 -04:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2015-04-27 22:41:44 -04:00
										 |  |  | }); |