3

I'm trying to use Forever to keep my nodejs scripts up and running

As per Forever's homepage it says

  [Long Running Process]
    The forever process will continue to run outputting log messages to the console.
    ex. forever -o out.log -e err.log my-script.js

  [Daemon]
    The forever process will run as a daemon which will make the target process start
    in the background. This is extremely useful for remote starting simple node.js scripts
    without using nohup. It is recommended to run start with -o -l, & -e.
    ex. forever start -l forever.log -o out.log -e err.log my-daemon.js
        forever stop my-daemon.js

However I fail to understand the difference between the two. Under what conditions should I use a long running process vs a daemon?

4

The difference is in the will continue to run outputting log messages to the console part. A daemon is a long running process that doesn't have any reference to the console that launched it originally.

Removing the reference takes a couple of additional steps (closing the original input and output file descriptors) known as 'detaching'.

  • Kind of like the jump from artificial intelligence and real intelligence lol or before you are 18 with the string attached to you, after you become an adult you would be a demon process that is not tied to a parent shell. – Joe May 1 '13 at 22:53
  • Will a Long Running Process continue to run even if I log out of the SSH session? – Kevin Boyd May 2 '13 at 4:33
  • 1
    Hmmm, I'm not sure how forever will react to the console disapearing. If you want to use the 'Long Running Process' from an ssh session, your best bet is probably to run it in a screen or a tmux session – Frederik Deweerdt May 2 '13 at 4:40
  • Thanks for the update! also when I run my script with "forever start myscript.js" and then check all currently running node processes with "ps aux | grep node" It shows me 2 processes running. Any idea why this would happen? – Kevin Boyd May 2 '13 at 4:43
  • 1
    Yes, the parent is the watchdog: it keeps an eye on the children (which actually runs your program). The watchdog's task is to keep an eye on the children and to restart it if needed – Frederik Deweerdt May 2 '13 at 4:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.