Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
ParseServer.prototype.start = function() {
this.load();
var child = new (forever.Monitor)("./server.js", this.conf);
child.on('watch:restart', function(info) {
console.error('Restaring script because ' + info.file + ' changed');
});
child.on('restart', function() {
console.error('Forever restarting script for ' + child.times + ' time');
});
child.on('exit:code', function(code) {
console.error('Forever detected script exited with code ' + code);
});
// Start!
child.start();
init: function(simulationMode) {
YOLO.simulationMode = simulationMode;
var yoloParams = config.NEURAL_NETWORK_PARAMS[config.NEURAL_NETWORK];
var videoParams = config.VIDEO_INPUTS_PARAMS[config.VIDEO_INPUT];
YOLO.process = new (forever.Monitor)(['./darknet','detector','demo', yoloParams.data , yoloParams.cfg, yoloParams.weights, videoParams, '-ext_output','-dont_show','-json_port','8070', '-mjpeg_port', '8090'],{
max: 1,
cwd: config.PATH_TO_YOLO_DARKNET,
killTree: true
});
YOLO.process.on("start", () => {
console.log('Process YOLO started');
YOLO.isStarted = true;
YOLO.isStarting = false;
});
YOLO.process.on("stop", () => {
console.log('Process YOLO stopped');
YOLO.isStarted = false;
});
function forever_bind(logname, start_script, opts, route) {
logger.info('starting [' + logname + '] with script ' + start_script);
var child = new (forever.Monitor)(start_script, opts);
child.once('error', function(err) { process_error(logname, err); });
child.once('start', function(process, data) { process_start(logname, process, data, opts); });
child.on('stop', function(process) { process_stop(logname, process); });
child.on('restart', function() { process_restart(logname); });
child.once('exit', function() { process_exit(logname); });
child.on('stdout', function(data) { process_stdout(logname, data); });
child.on('stderr', function(data) { process_stderr(logname, data); });
child.on('message', function(data) {
if (gardener_http && data.port) {
logger.info('process [' + logname + '] has bound to port ' + data.port);
gardener_http.add_app(route, data.port);
}
});
child.start();
return child;
const env = {
EDGEMICRO_KEY:options.key,
EDGEMICRO_SECRET:options.secret,
SOURCE_CONFIG_PATH:source,
TARGET_CONFIG_PATH: target,
IGNORE_CACHE_CONFIG: options.ignorecachedconfig ? true : false
};
const max = config.edgemicro.restart_max ? config.edgemicro.restart_max : 50;
const sleep = config.edgemicro.restart_sleep ? config.edgemicro.restart_sleep : 1000;
const up = config.edgemicro.min_up_time ? config.edgemicro.min_up_time : 10000;
console.log("config: min_up_time:",up);
console.log("config: spin_sleep_time:",sleep);
console.log("config: max_times:",max);
child = new (forever.Monitor)('./lib/process-instance.js', {
max: max,
spinSleepTime: sleep,
minUptime: up,
env: env
});
child.on('exit', function () {
console.error('server has exited after 3 restarts');
});
child.start();
};
function createMoninor(config) {
const monitor = new forever.Monitor(config.script, {
silent: true,
max: 1,
env: config.env,
});
monitor.on('stdout', (buffer) => {
const message = buffer.toString();
if (config.onListening && /listening/.test(message)) {
config.onListening(config.key);
}
log(config.key, message);
});
monitor.on('stderr', log.bind(null, config.key));
var createForeverServer = function() {
/**
* Forever server configurations for launching the spacebrew server in forever mode
* @type {forever.Monitor}
*/
var server = new (forever.Monitor)('node_server.js', {
'silent': false
, 'options': argv
, 'uid': 'spacebrew'
, 'pid': './data/'
, 'logFile': './data/log/spacebrew_forever_' + date + '.log'
, 'outFile': './data/log/spacebrew_info_' + date + '.log'
, 'errFile': './data/log/spacebrew_error_' + date + '.log'
});
/**
* Register event handler for application exit events
* @return {[type]} [description]
*/
server.on('exit', function () {
logger.log('info','[Exit] the spacebrew server will no longer be restarted');
});
compiler.watch(100, (err, stats) => {
if (err) {
throw err;
}
if (!monitor) {
monitor = new forever.Monitor(script, {
max: 1,
});
monitor.once('start', onBuild.bind(null, stats));
monitor.start();
} else {
monitor.once('restart', onBuild.bind(null, stats));
monitor.restart();
}
});
function startFactory()
{
notice('[notice] attempting to fork and start irc-factory with forever');
var client = new (forever.Monitor)('lib/factory.js', {
max: 3,
silent: true,
sourceDir: 'irc-factory',
logFile: 'logs/factory.forever.log',
outFile: 'logs/factory.forever.log',
errFile: 'logs/factory.error.log',
options: [program.config]
});
client.on('start', function()
{
setTimeout(function()
{
success('[success] irc-factory successfully started');
startBackend();