explaingit

foreversd/forever

13,847JavaScriptAudience · ops devopsComplexity · 2/5Setup · easy

TLDR

Forever is a command-line tool that keeps a Node.js script running continuously by automatically restarting it whenever it crashes or exits, running the process as a background daemon.

Mindmap

mindmap
  root((forever))
    Core feature
      Auto-restart on crash
      Background daemon
      Process list
    Commands
      forever start
      forever list
      forever stop
    Options
      Log redirection
      Restart cap
      File watching
    Notes
      Community maintained
      pm2 recommended instead
Click or tap to explore — scroll the page freely

Code map

Detail Auto

An interactive map of this repo's files and how they connect — its source is parsed live in your browser. Click Visualize to build it.

filefunction / class

Things people build with this

USE CASE 1

Keep a Node.js web server running as a background daemon that automatically restarts after crashes.

USE CASE 2

Watch a source directory for file changes and auto-restart a Node.js app on edits during development.

USE CASE 3

Define multiple Node.js apps in a JSON config file and start, stop, or restart them all with one command.

USE CASE 4

Cap how many times a crashed script is allowed to restart before giving up, and redirect its output to a log file.

Tech stack

JavaScriptNode.jsnpm

Getting it running

Difficulty · easy Time to first run · 5min

Project is community-maintained, the original authors recommend pm2 or nodemon for new projects.

No license information is mentioned in the explanation.

In plain English

Forever is a command-line tool for Node.js that keeps a script running at all times. If the script crashes or exits, forever detects this and starts it again automatically. You install it once globally via npm, then use it to wrap any script you want to keep alive. The basic workflow is simple: instead of running "node app.js" directly, you run "forever start app.js". The process moves to the background as a daemon, and forever watches over it. If it dies, forever restarts it. You can see all running scripts with "forever list", stop them by name or ID, restart them, or tail their log files, all from the command line. Beyond simple restarts, the tool offers a range of options. You can cap how many times a script is allowed to restart before giving up, redirect its output and error streams to log files, watch the source directory for file changes and restart on edits, and control the minimum uptime a process must reach before forever stops treating it as a crash loop. Configuration can be passed as command-line flags or written into a JSON file, which also lets you define multiple apps to start together. The README notes that this project is now maintained by the community rather than by an active core team. For new projects, the authors themselves suggest looking at alternatives like pm2 or nodemon, which have more active maintenance and broader feature sets. Forever also exposes a programmatic API, though the README recommends installing the companion package forever-monitor for that use case rather than the main CLI package. The programmatic side is geared toward developers who want process-management behavior built into their own Node.js applications rather than managed from a terminal.

Copy-paste prompts

Prompt 1
My Node.js API server keeps crashing in production. Show me how to use forever to run it as a background daemon that auto-restarts, and how to tail its logs.
Prompt 2
Create a forever.json config file that starts two Node.js apps simultaneously, sets separate log file paths for each, and limits restarts to 10 before giving up.
Prompt 3
How do I use forever to watch my source folder for file changes and automatically restart my Node.js app during development?
Prompt 4
Show me the forever CLI commands to list all running processes, restart a specific one by name, and stop everything cleanly.
Open on GitHub → Explain another repo

← foreversd on gitmyhub — every repo by this author, as a profile.

Verify against the repo before relying on details.