|
|
|
@ -246,31 +246,38 @@ nconf.argv().env().file({
|
|
|
|
|
file: path.join(__dirname, '/config.json')
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
if (nconf.get('daemon') !== false) {
|
|
|
|
|
if (fs.existsSync(pidFilePath)) {
|
|
|
|
|
try {
|
|
|
|
|
var pid = fs.readFileSync(pidFilePath, { encoding: 'utf-8' });
|
|
|
|
|
process.kill(pid, 0);
|
|
|
|
|
process.exit();
|
|
|
|
|
} catch (e) {
|
|
|
|
|
fs.unlinkSync(pidFilePath);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
fs.open(path.join(__dirname, 'config.json'), 'r', function(err) {
|
|
|
|
|
if (!err) {
|
|
|
|
|
if (nconf.get('daemon') !== false) {
|
|
|
|
|
if (fs.existsSync(pidFilePath)) {
|
|
|
|
|
try {
|
|
|
|
|
var pid = fs.readFileSync(pidFilePath, { encoding: 'utf-8' });
|
|
|
|
|
process.kill(pid, 0);
|
|
|
|
|
process.exit();
|
|
|
|
|
} catch (e) {
|
|
|
|
|
fs.unlinkSync(pidFilePath);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
require('daemon')({
|
|
|
|
|
stdout: process.stdout,
|
|
|
|
|
stderr: process.stderr
|
|
|
|
|
});
|
|
|
|
|
require('daemon')({
|
|
|
|
|
stdout: process.stdout,
|
|
|
|
|
stderr: process.stderr
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
fs.writeFile(__dirname + '/pidfile', process.pid);
|
|
|
|
|
}
|
|
|
|
|
fs.writeFile(__dirname + '/pidfile', process.pid);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async.series([
|
|
|
|
|
Loader.init,
|
|
|
|
|
Loader.displayStartupMessages,
|
|
|
|
|
Loader.start
|
|
|
|
|
], function(err) {
|
|
|
|
|
if (err) {
|
|
|
|
|
console.log('[loader] Error during startup: ' + err.message);
|
|
|
|
|
async.series([
|
|
|
|
|
Loader.init,
|
|
|
|
|
Loader.displayStartupMessages,
|
|
|
|
|
Loader.start
|
|
|
|
|
], function(err) {
|
|
|
|
|
if (err) {
|
|
|
|
|
console.log('[loader] Error during startup: ' + err.message);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
} else {
|
|
|
|
|
// No config detected, kickstart web installer
|
|
|
|
|
var child = require('child_process').fork('app');
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|