Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function startDaemon(options) {
var monitor, outFD, errFD;
options.uid = options.uid || crypto.randomBytes(3).toString('base64').replace(/[\+\/]/g, '_');
options.logFile = forever.logFilePath(options.logFile || options.uid + '.log');
options.pidFile = forever.pidFilePath(options.pidFile || options.uid + '.pid');
options.options = process.argv;
outFD = fs.openSync(options.logFile, 'a');
errFD = fs.openSync(options.logFile, 'a');
process.argv[2] = 'run';
process.argv.splice(0, 2);
monitor = child_process.spawn(process.execPath, [MONITOR_PATH, SCRIPT_PATH], {
stdio: ['ipc', outFD, errFD],
detached: true
});
monitor.on('exit', function (code) {
console.error('Monitor died unexpectedly with exit code %d', code);
});
monitor.send(JSON.stringify(options));