Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
/**
* Bootstrapper for remote-daemon.js
*
* Triggered by first run of sicksync client, through ssh connection
* This file should only run on your devbox, (IE, in the data center).
*
*/
console.log('starting daemon');
var forever = require('forever'),
daemonFilePath = './sicksync-dev/lib/remote-daemon.js';
// TODO: change these files paths, right now they output to user's home location on remote server
// due to the fact that the process.cwd() is /home/cdopuch
var daemon = forever.startDaemon(
daemonFilePath,
{
// NOTE: these log files are truncated on each new run
// TODO: rotate the logs so we can save old logs
'logFile': 'new-remote-daemon.log',
'outFile': 'new-remote-daemon-stdout.log',
'errFile': 'new-remote-daemon-stderr.log',
'max': 1,
'uid': 'remote-daemon'
}
);
var server = forever.startServer(daemon);
// process.stdout.write('[remote.js] up and waiting');
console.log('[remote.js] up and waiting');
.action(function () {
var script = path.join(__dirname, 'app.js');
forever.startDaemon (script, {});
console.log("blititor server is started...");
});
function launch() {
forever.startDaemon('main.js', {
'uid': 'fbash',
'script': 'index.js',
'sourceDir': __dirname,
'logFile': path.join(fbashDir, 'forever.log'),
'outFile': path.join(fbashDir, 'out.log'),
'errFile': path.join(fbashDir, 'err.log')
});
console.log('Started fbash.');
}
fsx.mkdirs(lazoPath + '/logs', function (err) {
if (!err) {
forever.load({ root: lazoPath + '/logs', pidPath: lazoPath });
forever.startDaemon('./lib/server/app.js', {
logFile: 'lazo.log',
pidFile: 'lazo.pid',
errFile: 'lazo.err',
sourceDir: lazoPath,
a: true
});
} else {
console.error(err);
}
});
}
function _start() {
var child = forever.startDaemon(masterScript, foreverOptions);
logger.info('log file ' + foreverOptions.logFile);
logger.info('open http://local.fd.server/ to check the server!');
}
forever.stop(foreverOptions.uid).on('stop', _start).on('error', _start);
forever.list(false, function(err, processes, a) {
var running = false;
if (processes) {
running = processes.some(function(process) {
return (process.file == '../api.js');
});
}
if (!running) {
var child = forever.startDaemon('../api.js', {
max: 3,
silent: true,
options: []
});
}
});
var startBalancer = function () {
var child = forever.startDaemon(balancerFilePath, {
uid: balancerUid,
max: MAX_RESTARTS,
logFile: logFileName,
outFile: logFileName,
errFile: logFileName,
args: commandRawArgs
});
forever.startServer(child);
successMessage('Started loadbalancer - Logging to ' + logFileName);
};
caddis.start = function(port, callback) {
mkdirp.sync(tmp);
if(fs.existsSync(caddis.outlog)) {
fs.writeFileSync(caddis.outlog, '', 'utf8');
}
generateServerScript(port, caddis.original, caddis.server);
forever.startDaemon(caddis.server, {
logFile: caddis.outlog,
append: false
})
.on('error', function(error) {
callback(error);
});
checkRegistry(caddis.server, callback);
};