-
-
Save chase2981/e88afee41ccf480b975a5e34a329bd7d to your computer and use it in GitHub Desktop.
Forever example with config file
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
// Sample configuration for app in /home/myuser/app dir | |
"uid": "app", | |
"max": 5, // restart the app successively maximum of 5 times | |
"spinSleepTime": 1000, // time to wait until a next restart is attempted (in ms) | |
"append": true, // append the logs, do not overwrite | |
"watch": true, // watch for changes and restart if they occur | |
"script": "server.js", // main startup script (almost like issuing node server.js) | |
"sourceDir": "/home/myuser/app", // the dir where your entire app code resides (dir structure is recursively traversed) | |
"args": ["--myAPIKey", "xBlzdn84fa"] // pass any arguments to your app | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# install forever globally | |
npm i forever | |
# run forever with a config file | |
forever start /home/myuser/app/forever-config.json | |
# list running scripts with forever list | |
forever list | |
# checks logs with following command | |
forever logs | |
#restart all scripts should you need to | |
forever restart all | |
# stop running script with stop or stopall | |
# forever stopall |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment