DEV Community

San
San

Posted on • Edited on

Run the script in the background using npm forever cmd

Installing forever

npm i -g forever
Enter fullscreen mode Exit fullscreen mode

Running a script with forever

forever start app.js
Enter fullscreen mode Exit fullscreen mode

After you start the script, you can list all the running processes.

forever list
Enter fullscreen mode Exit fullscreen mode

forever

Some other useful forever commands:

forever start: starts a script as a daemon
forever stop: stops the daemon script by Id|Uid|Pid|Index|Script
forever stopall: stops all running scripts
forever restart: restarts the daemon script
forever restartall: restarts all running forever scripts
forever cleanlogs: deletes all historical forever log files
forever config: lists all forever user configurations
forever set : defines a forever config value for an unique key
forever clear : clears the specified forever config by its key
Enter fullscreen mode Exit fullscreen mode

Run your customize script

  • Navigate your file:eg /var/www/frontend
  • Where package.json is available
forever start -c "npm run dev" ./

Enter fullscreen mode Exit fullscreen mode

Top comments (0)