How to Use Forever in Linux for Node.js

2014/05/312 min read
bookmark this
Responsive image

Table of Contents

  1. What is Forever?
  2. List All Running Forever Threads
  3. Stop a Specific Forever Thread
  4. Start a Specific Forever Thread

Introduction

Forever is an npm package for your Node.js server-side application. It allows you to keep your Node.js application running even after you log off your machine.

What is Forever?

Forever is an npm package for your Node.js server-side application. Check out the package documentation at forever npm package.

Use Forever so that even though you log off your machine, the Node.js application will still keep running. Without this, after you log off, your application will stop.

The following are a few common commands for running Forever on a Linux system.

List All Running Forever Threads

/# forever list

Stop a Specific Forever Thread

/# forever stop server.js

Start a Specific Forever Thread

The following example is similar to node server.js:

/# forever start server.js

Conclusion

Forever is a simple and effective tool for keeping your Node.js applications running in the background on Linux. With just a few commands, you can start, stop, and list your running Node.js processes.