bin/conquer.js
function start(noMsg) {
	if ((noMsg || false) !== true)
		logger.log('Starting', clc.green(script), 'with', clc.magenta(parser));
	
	if (instance)
		return;
	
	// Spawn an instance of the parser that will run the script.
	instance = spawn(parser, parserParams);
	
	// Redirect the parser/script's output to the console.
	instance.stdout.on('data', function (data) { 
		logger.scriptLog(scriptName, data.toString()); 
	});
	instance.stderr.on('data', function (data) { 
		logger.scriptLog(scriptName, data.toString(), true); 
	});
	instance.stderr.on('data', function (data) {
		if (/^execvp\(\)/.test(data.toString())) {
			logger.error('Failed to restart child process.');
			process.exit(0);
		}
	});
	instance.on('exit', function (code, signal) {
		instance = null;
	
		if (signal == 'SIGUSR2') {
			logger.error('Signal interuption');
			start();
			return;
		}
		
		logger.log(clc.green(script), 'exited with code', clc.yellow(code));
		notifyWebSocket('exit');
		
		if (keepAlive || (restartOnCleanExit && code == 0)) {
			start();
			return;
		}
	});
}
function start(noMsg) {
	if ((noMsg || false) !== true)
		logger.log('Starting', clc.green(script), 'with', clc.magenta(parser));
	
	if (instance)
		return;
	
	// Spawn an instance of the parser that will run the script.
	instance = spawn(parser, parserParams);
	
	// Redirect the parser/script's output to the console.
	instance.stdout.on('data', function (data) { 
		logger.scriptLog(scriptName, data.toString()); 
	});
	instance.stderr.on('data', function (data) { 
		logger.scriptLog(scriptName, data.toString(), true); 
	});
	instance.stderr.on('data', function (data) {
		if (/^execvp\(\)/.test(data.toString())) {
			logger.error('Failed to restart child process.');
			process.exit(0);
		}
	});
	instance.on('exit', function (code, signal) {
		instance = null;
	
		if (signal == 'SIGUSR2') {
			logger.error('Signal interuption');
			start();
			return;
		}
		
		logger.log(clc.green(script), 'exited with code', clc.yellow(code));
		notifyWebSocket('exit');
		
		if (keepAlive || (restartOnCleanExit && code == 0)) {
			start();
			return;
		}
	});
}
function start ( noMsg ) { if ( ( noMsg || false ) !== true ) logger . log ( 'Starting' , clc . green ( script ) , 'with' , clc . magenta ( parser ) ) ; if ( instance ) return ; // Spawn an instance of the parser that will run the script. instance = spawn ( parser , parserParams ) ; // Redirect the parser/script's output to the console. instance . stdout . on ( 'data' , function ( data ) { logger . scriptLog ( scriptName , data . toString ( ) ) ; } ) ; instance . stderr . on ( 'data' , function ( data ) { logger . scriptLog ( scriptName , data . toString ( ) , true ) ; } ) ; instance . stderr . on ( 'data' , function ( data ) { if ( / ^execvp\(\) / . test ( data . toString ( ) ) ) { logger . error ( 'Failed to restart child process.' ) ; process . exit ( 0 ) ; } } ) ; instance . on ( 'exit' , function ( code , signal ) { instance = null ; if ( signal == 'SIGUSR2' ) { logger . error ( 'Signal interuption' ) ; start ( ) ; return ; } logger . log ( clc . green ( script ) , 'exited with code' , clc . yellow ( code ) ) ; notifyWebSocket ( 'exit' ) ; if ( keepAlive || ( restartOnCleanExit && code == 0 ) ) { start ( ) ; return ; } } ) ; }
Starts and instance of the parser if none is running.
@param {Boolean} [noMsg] - indicates if no message should be written to the
log. Defaults to false.
Starts and instance of the parser if none is running .