gitmyhub

forever

JavaScript ★ 4 updated 13y ago ⑂ fork

A simple CLI tool for ensuring that a given script runs continuously (i.e. forever)

Forever is a tool that automatically restarts a script or program whenever it crashes, keeping servers and background tasks running continuously.

Node.jsJavaScriptsetup: easycomplexity 2/5

Plain-English Explanation: Forever

Forever is a tool that automatically restarts a script or program if it crashes or stops running. Instead of manually restarting your application every time something goes wrong, you run it through forever and it keeps bringing the program back to life—hence the name. This is especially useful for server applications or background tasks that need to stay online continuously.

The tool works in two ways. You can use it from the command line by typing a simple command like forever start my-app.js, and it will monitor that script and restart it automatically if it fails. You can also use it as a library within your own Node.js code to programmatically manage which scripts stay running. The tool keeps logs of what happens, so you can review errors and output later. It also lets you run multiple scripts at once and stop or restart them all together.

Who would use this? Developers running production servers, background workers, or any long-running processes that shouldn't go down if something breaks. For example, if you have a chat server or a job processor that needs to be available 24/7, you'd wrap it with forever to ensure it automatically recovers from unexpected crashes. It saves you from waking up at 3 AM to manually restart a service—the system handles it for you.

The README also notes that if you want to use forever within your own code (rather than just as a command-line tool), you should install a separate package called forever-monitor instead. This keeps things lightweight if you only need the CLI version.

Where it fits