The github readme of forever.js states
In addition to passing forever the path to a script (along with accompanying options, described above), you may also pass forever the path to a JSON file containing these options. For example, consider an application with the following file structure:
In the following example, the options uid
, append
, watch
, script
and sourceDir
are set. All of these are long versions of arguments to the forever
command (with the short versions being -a
, -w
, -s
).
My problem is: some of the options to forever
don't have a long version, for example -m
, -l
, -e
, -o
. How do I provide these options in my json configuration file?
I've tried adding values to keys such as "l"
and "log"
, but this didn't achieve the desired effect.
Forever is an npm package used to keep your script running continuously in the background. It's a handy CLI tool that helps you to manage your application in the development and production stages. To start running a script with forever, use the forever start command, followed by the script name.
What is forever? Forever is an npm module that ensures a Node. js script continuously runs in the background on the server. It's a helpful CLI tool for the production environment because it helps manage the Node applications and their processes.
Use npx to solve the error "forever: command not found", e.g. npx forever start app. js or install the package globally by running npm install -g forever to be able to use the command without the npx prefix. The fastest way to solve the error is to use the npx command.
It seems like the JSON properties for all shorthand options are listed here. For example, the JSON property for -p
would be "path"
.
var argvOptions = cli.argvOptions = {
'command': {alias: 'c'},
'errFile': {alias: 'e'},
'logFile': {alias: 'l'},
'killTree': {alias: 't', boolean: true},
'append': {alias: 'a', boolean: true},
'fifo': {alias: 'f', boolean: true},
'number': {alias: 'n'},
'max': {alias: 'm'},
'outFile': {alias: 'o'},
'path': {alias: 'p'},
'help': {alias: 'h'},
'silent': {alias: 's', boolean: true},
'verbose': {alias: 'v', boolean: true},
'watch': {alias: 'w', boolean: true},
'debug': {alias: 'd', boolean: true},
'plain': {boolean: true},
'uid': {alias: 'u'}
};
logFile, outFile, errFile worked for me too. :)
in my case, I used : myapp_config.json
{
"uid": "myapp",
"append": true,
"watch": true,
"script": "myscript.js",
"sourceDir": "/home/myaccount/myproj/myapp",
"logFile": "/home/myaccount/.forever/forever.log",
"outFile": "/home/myaccount/.forever/out.log",
"errFile": "/home/myaccount/.forever/err.log"
}
usage:
forever start myapp_config.json
forever stop myapp
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With