Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6096011
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T12:52:37+00:00 2026-05-23T12:52:37+00:00

I have a few, possibly trivial, questions with using forever with Node.js. From what

  • 0

I have a few, possibly trivial, questions with using forever with Node.js. From what I have read, forever can be used programatically and it maintains a list with all the scripts that use forever. When that process dies, it automatically spawns a new one until it is stopped.

However, my question is, how does forever do this? Does it add these scripts to be started on boot as well?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T12:52:38+00:00Added an answer on May 23, 2026 at 12:52 pm

    You can use forever programatically like this:

    Using an instance of Forever inside a node.js script:

    var forever = require('forever-monitor');
    
      var child = new (forever.Monitor)('your-filename.js', {
        max: 3,
        silent: true,
        options: []
      });
    
      child.on('exit', function () {
        console.log('your-filename.js has exited after 3 restarts');
      });
    
      child.start();
    

    You should take a minute and read over the options available in the excellent documentation for Forever in the README.md

    You have a number of events that can be listened for in Forever as well:

    • error [err]: Raised when an error occurs
    • start [process, fvrFile, data]: Raise when the target script is first started.
    • stop [process]: Raised when the target script is stopped by the user
    • save [path, data]: Raised when the target Monitor saves the pid information to disk.
    • restart [forever]: Raised each time the target script is restarted
    • exit [forever]: Raised when the target script actually exits (permenantly).
    • stdout [data]: Raised when data is received from the child process’ stdout
    • stderr [data]: Raised when data is received from the child process’ stderr

    It does this by attaching event listeners to the script you’re trying to run and handling them in a graceful manner.

    The code is pretty well documented if you want to take a look at exactly how it does it.

    You should also read this excellent tutorial on how to keep a process running forever.

    As for the second question: No, it does not add it to start at boot. For that, you’d need to add it as an upstart job or use something like Monit to monitor and start it. For that, you should take a look at Deploying Node.js with Upstart and Monit. It’s a great tutorial.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a few questions about security using PHP, I dont want to use
I have a few questions related: 1) Is possible to make my program change
Ok, I have asked a few questions about different facets of trying to accomplish
We have a few C++ solutions and we run some build scripts using batch
This is a sample of my XML, it can possibly have thousands of rows
I have a few related questions about managing aligned memory blocks. Cross-platform answers would
I have a few bash scripts I run, but they can take several hours
I've tried to read up on Caching in ASP.NET and still have a few
I have a web service that I would like to use from a few
I have a few log files like these: /var/log/pureftpd.log /var/log/pureftpd.log-20100328 /var/log/pureftpd.log-20100322 Is it possible

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.