I found that forever can run nodejs server forever. Is forever supports this feautre?
-- If the nodejs script is modified changed, the server shld restarted automatically.
How can I enable this feature using forever? or I need something else?
I found that forever can run nodejs server forever. Is forever supports this feautre?
-- If the nodejs script is modified changed, the server shld restarted automatically.
How can I enable this feature using forever? or I need something else?
I personally use Nodemon to handle that. Its a replacement for the node server. It automatically restarts the server when your files are updated. You might want to check it out.
From the forever readme. Use the -w
flag to watch file for changes.
In case someone else, like myself, comes to find this through google.
I have to run it thusly:
forever --watch ./start/file
For me, at least, it defaults to watching the current directory I'm running the command in for changes. ./start/file is the file that "npm start" hits up from your package.json.
If you need to watch a different directory from where you're pwd shows you to be, try:
forever --watch --watchDirectory ./path/to/dir ./start/file
For some reason "forever start xxxxxxxxx" only brings up the help information for me, but this works. /me shrugs.
Again just another example of its usage (and it does work :D)
forever -w --watchDirectory . --watchIgnore *.log -o ./log/out.log -e ./log/err.log index.js
That will launch the app in the same process with output to stdout/stderr (but also written to the logs)
To launch it in prod watching is obviously not a good idea and running it as a deamon is probably what you are after so drop the -w flags and add the "start" command
forever -o ./log/out.log -e ./log/err.log start index.js