diff --git a/README.md b/README.md index a1c45a4..fbd55da 100644 --- a/README.md +++ b/README.md @@ -72,7 +72,9 @@ forever-service version 0.x.x -h, --help output usage information -s, --script [script] Script to run as service e.g. app.js, defaults to app.js - + + -o --scriptOptions [options] Command line options for the script + --minUptime [value] Minimum uptime (millis) for a script to not be considered "spinning", default 5000 --spinSleepTime [value] Time to wait (millis) between launches of a spinning script., default 2000 @@ -141,7 +143,16 @@ $ sudo forever-service install test --script main.js * Custom options for forever ``` -$ sudo forever-service install test -f " -watchDirectory /your/watch/directoyr -w" +$ sudo forever-service install test -f " -watchDirectory /your/watch/directory -w" +``` + + + + +* Command line parameters for the script + +``` +$ sudo forever-service install test --script main.js -o " param1 param2" ``` @@ -154,6 +165,14 @@ $ sudo forever-service delete test This command will stop service if running, clean up all provisioned files and service + + +* Get list of running services (Remember all forever command line options are available since we use forever internally) +``` +$ sudo forever list +``` + + Known Issue(s) -------------- "restart service" command works like stop in Ubuntu due to bug in upstart https://bugs.launchpad.net/upstart/+bug/703800 diff --git a/bin/forever-service b/bin/forever-service index 2f82a42..3b3635c 100755 --- a/bin/forever-service +++ b/bin/forever-service @@ -21,6 +21,8 @@ platforms.get(function(err, platform){ .command('install [service]') .option('-s, --script [script]','Script to run as service e.g. app.js, defaults to app.js') .option('','') + .option('-o --scriptOptions [options]','Command line options for the script') + .option('','') .option('--minUptime [value]','Minimum uptime (millis) for a script to not be considered "spinning", default 5000') .option('','') .option('--spinSleepTime [value]','Time to wait (millis) between launches of a spinning script., default 2000') @@ -69,6 +71,8 @@ platforms.get(function(err, platform){ else ctx.script = 'app.js'; + + if(options.scriptOptions) ctx.scriptOptions = options.scriptOptions; if(options.minUptime) ctx.minUptime = options.minUptime; if(options.spinSleepTime) ctx.spinSleepTime = options.spinSleepTime; if(options.noGracefulShutdown) ctx.killSignal = 'SIGKILL'; //Default is SIGTERM so non graceful shutdown makes it SIGKILL diff --git a/package.json b/package.json index 0a36fca..894d217 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "forever-service", - "version": "0.4.1", + "version": "0.4.2", "preferGlobal": "true", "description": "Provision node script as a service via forever, allowing it to automatically start on boot, working across various Linux distros and OS", "main": "lib/api.js", diff --git a/templates/sysvinit/initd.template b/templates/sysvinit/initd.template index 75c3684..4714b25 100644 --- a/templates/sysvinit/initd.template +++ b/templates/sysvinit/initd.template @@ -98,7 +98,7 @@ start() { --killSignal $KILL_SIGNAL \ {{foreverOptions|default('')}} \ --uid {{service}} \ - start {{script|default('app.js')}} 2>&1 >/dev/null + start {{script|default('app.js')}} {{scriptOptions|default('')}} 2>&1 >/dev/null RETVAL=$? [ $RETVAL = 0 ] && touch $LOCKFILE diff --git a/templates/upstart/upstart.template b/templates/upstart/upstart.template index 7b05b72..db288c9 100644 --- a/templates/upstart/upstart.template +++ b/templates/upstart/upstart.template @@ -41,7 +41,7 @@ env KILLWAITTIME={{forceKillWaitTime|default('5000')}} chdir {{cwd}} -exec {{foreverPath}}forever -a -l $LOGFILE --minUptime $MIN_UPTIME --spinSleepTime $SPIN_SLEEP_TIME --killSignal $KILL_SIGNAL {{foreverOptions|default('')}} --uid {{service}} start {{script|default('app.js')}} +exec {{foreverPath}}forever -a -l $LOGFILE --minUptime $MIN_UPTIME --spinSleepTime $SPIN_SLEEP_TIME --killSignal $KILL_SIGNAL {{foreverOptions|default('')}} --uid {{service}} start {{script|default('app.js')}} {{scriptOptions|default('')}} post-start script echo "{{service}} started"