diff --git a/init.d/forever-services b/init.d/forever-services index 2d84f3d2..7d085ce3 100644 --- a/init.d/forever-services +++ b/init.d/forever-services @@ -22,7 +22,6 @@ node=node forever=`which forever` awk=awk sed=sed -echo `env` start() { echo "Starting $NAME node instance: " @@ -36,7 +35,7 @@ start() { chown $USER $pidfile # Launch the application - start_daemon -p $pidfile $forever service-start -p $forever_dir + start_daemon -p $pidfile -- $forever service-start -p $forever_dir else echo "Instance already running" fi diff --git a/lib/forever/cli.js b/lib/forever/cli.js index c065e90a..9fa5832b 100644 --- a/lib/forever/cli.js +++ b/lib/forever/cli.js @@ -288,14 +288,20 @@ cli['service-start'] = function (file, options) { forever.log.info('No services found.'); return; } - serviceFiles.forEach(function (serviceFile) { + var monitors = []; + serviceFiles.forEach(function (serviceFile, index) { var serviceFilePath = path.join(forever.config.get('root'), 'services', serviceFile); var service = JSON.parse(fs.readFileSync(serviceFilePath)); var file = service.file; forever.log.info('Starting service for ' + file); var options = service.options; options.minUptime = 200; - cli.start(file, options, false); + var monitor = new forever.Monitor(file, options); + monitor.start(); + monitors.push(monitor); + if(index === serviceFiles.length - 1) { + forever.startServer.apply(forever, monitors); + } }); } cli['service-stop'] = function (file, options) {