
Security News
Axios Supply Chain Attack Reaches OpenAI macOS Signing Pipeline, Forces Certificate Rotation
OpenAI rotated macOS signing certificates after a malicious Axios package reached its CI pipeline in a broader software supply chain attack.
forever-service
Advanced tools
Provision node script as a service via forever, allowing it to automatically start on boot, working across various Linux distros and OS
Make provisioning node script as a service simple.
We love nodejs for server development. But, It is surprising to find that there is no standard tool to provision script as a service. Forever kind of tools comes close but they only demonize the process and not provision as service; which can be automatically started on reboots. To make matter worse, each OS and Linux distro has its own unique way of provisioning the services correctly.
forever must be installed globally using
npm install -g forever
npm install -g forever-service
$ forever-service --help
forever-service version 0.x.x
Usage: forever-service [options] [command]
Commands:
install [options] [service]
Install node script (defaults to app.js in current directory) as service via forever
delete [service]
Delete all provisioned files for the service, will stop service if running before delete
Options:
-h, --help output usage information
-V, --version output the version number
$ forever-service install --help
forever-service version 0.x.x
Usage: install [options] [service]
Options:
-h, --help output usage information
-s, --script [script] Script to run as service e.g. app.js, defaults to app.js
-e --envVars [vars] Environment Variables for the script
e.g. -e "PORT=80 ENV=prod FOO=bar"
-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
--noGracefulShutdown Disable graceful shutdown
-t --forceKillWaitTime [waittime] Time to wait in milliseconds before force killing; after failed graceful stop
defaults to 5000 ms, after which entire process tree is forcibly terminated
-f --foreverOptions " [options]" Extra command line options for forever
e.g. -f " --watchDirectory /your/watch/directory -w -c /custom/cli" etc..
NOTE: a mandatory space is required after double quotes, if begining with -
--start Start service after provisioning
--nologrotate Do not generate logrotate script
--logrotateFrequency [frequency] Frequency of logrotation
valid values are daily, weekly, monthly, "size 100k" etc, default daily
--logrotateMax [value] Maximum logrotated files to retain, default 10 (logrotate parameter)
--logrotateDateExt Archive old versions of log files adding a daily extension like YYYYMMDD instead of simply adding a number
--logrotateCompress Enable compression for logrotate
-p --foreverPath Path for forever cli e.g. /usr/local/bin,
by default forever cli is searched in system Path variable
-u --applyUlimits Apply increased ulimits in supported environment
-r --runAsUser [user] *Experimental* Run service as a specific user, defaults to root (No ubuntu support yet)
$ forever-service delete --help
forever-service version 0.x.x
Usage: delete [options] [service]
Options:
-h, --help output usage information
$ sudo forever-service install test
On Amazon Linux, This command will setup initd script and provision service using chkconfig, Create logrotate scripts
$ sudo forever-service install test --script main.js
$ sudo forever-service install test -f " --watchDirectory /your/watch/directory -w"
$ sudo forever-service install test --script main.js -o " param1 param2"
$ sudo forever-service delete test
This command will stop service if running, clean up all provisioned files and service
$ sudo forever list
forever allows to use -c command line parameter to point to alternate command line for execution, using that one can easily launch non-node apps also as service
$ sudo forever-service install javaservice1 -s start.jar -f " -c 'java -Xms1024m -Xmx1024m -jar'"
This command will run start.jar using java command line
$ sudo forever-service install phpservice1 -s info.php -f " -c php"
This command will run info.php using php command line
"restart service" command works like stop in Ubuntu due to bug in upstart https://bugs.launchpad.net/upstart/+bug/703800
Support other Linux distros, OSX, Windows etc.
Contributions are welcome, please send pull requests
Zapty - Seamless teamwork anywhere (Modern Communication, Task & Project management for teams)
FAQs
Provision node script as a service via forever, allowing it to automatically start on boot, working across various Linux distros and OS
The npm package forever-service receives a total of 233 weekly downloads. As such, forever-service popularity was classified as not popular.
We found that forever-service demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
OpenAI rotated macOS signing certificates after a malicious Axios package reached its CI pipeline in a broader software supply chain attack.

Security News
Open source is under attack because of how much value it creates. It has been the foundation of every major software innovation for the last three decades. This is not the time to walk away from it.

Security News
Socket CEO Feross Aboukhadijeh breaks down how North Korea hijacked Axios and what it means for the future of software supply chain security.