L'installation se fait comme d'habitude par la commande
sudo npm -g install foreverLe résultat doit etre:
/usr/local/lib/node_modules/forever
├── pkginfo@0.2.3
├── timespan@2.0.1
├── watch@0.5.0
├── microtime@0.2.0
├── daemon@0.4.1
├── node-fork@0.4.2
├── nssocket@0.3.7 (eventemitter2@0.4.8 lazy@1.0.8)
├── cliff@0.1.7 (colors@0.6.0-1 eyes@0.1.7)
├── portfinder@0.2.1 (mkdirp@0.0.7)
├── optimist@0.2.8 (wordwrap@0.0.2)
├── broadway@0.1.13 (colors@0.6.0-1 eventemitter2@0.4.8 optimist@0.3.1)
├── minimatch@0.0.5 (lru-cache@1.0.5)
├── utile@0.0.10 (async@0.1.18 mkdirp@0.3.0 rimraf@1.0.9 ncp@0.2.5)
├── flatiron@0.1.14 (director@1.0.9-1 optimist@0.3.1 prompt@0.1.12)
├── nconf@0.5.1 (async@0.1.18 ini@1.0.2 optimist@0.3.1)
├── ps-tree@0.0.2 (parse-table@0.0.0)
└── winston@0.5.10
Le lancement d'un programme par forever est très simple :
forever start 'monprogramme.js'
Exemple :(commande start et list)
forever start cluster1.js info: Forever processing file: cluster1.js german@german-1001PX:~$ german@german-1001PX:~$ forever list info: Forever processes running data: uid command script forever pid logfile uptime data: [0] YJVa node cluster1.js 2857 2858 /home/german/.forever/YJVa.log 0:0:0:7.882
Si le programme lancé par forever vient à tomber, il sera relancer automatiquement.
Forever est lui même en mode daemon (on peut fermer son terminal de lancement)
L'aide sur forever est la suivante:
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
german@german-1001PX:~$ forever --help | |
usage: forever [action] [options] SCRIPT [script-options] | |
Monitors the script specified in the current process or as a daemon | |
actions: | |
start Start SCRIPT as a daemon | |
stop Stop the daemon SCRIPT | |
stopall Stop all running forever scripts | |
restart Restart the daemon SCRIPT | |
restartall Restart all running forever scripts | |
list List all running forever scripts | |
config Lists all forever user configuration | |
set <key> <val> Sets the specified forever config <key> | |
clear <key> Clears the specified forever config <key> | |
logs Lists log files for all forever processes | |
logs <script|index> Tails the logs for <script|index> | |
columns add <col> Adds the specified column to the output in `forever list` | |
columns rm <col> Removed the specified column from the output in `forever list` | |
columns set <cols> Set all columns for the output in `forever list` | |
cleanlogs [CAREFUL] Deletes all historical forever log files | |
options: | |
-m MAX Only run the specified script MAX times | |
-l LOGFILE Logs the forever output to LOGFILE | |
-o OUTFILE Logs stdout from child script to OUTFILE | |
-e ERRFILE Logs stderr from child script to ERRFILE | |
-p PATH Base path for all forever related files (pid files, etc.) | |
-c COMMAND COMMAND to execute (defaults to node) | |
-a, --append Append logs | |
--pidfile The pid file | |
--sourceDir The source directory for which SCRIPT is relative to | |
--minUptime Minimum uptime (millis) for a script to not be considered "spinning" | |
--spinSleepTime Time to wait (millis) between launches of a spinning script. | |
--plain Disable command line colors | |
-d, --debug Forces forever to log debug output | |
-v, --verbose Turns on the verbose messages from Forever | |
-s, --silent Run the child script silencing stdout and stderr | |
-w, --watch Watch for file changes | |
-h, --help You're staring at it | |
[Long Running Process] | |
The forever process will continue to run outputting log messages to the console. | |
ex. forever -o out.log -e err.log my-script.js | |
[Daemon] | |
The forever process will run as a daemon which will make the target process start | |
in the background. This is extremely useful for remote starting simple node.js scripts | |
without using nohup. It is recommended to run start with -o -l, & -e. | |
ex. forever start -l forever.log -o out.log -e err.log my-daemon.js | |
forever stop my-daemon.js |
Sur stackoverflow : un exemple d'usage de forever à l'intérieur d'un programme.
Aucun commentaire:
Enregistrer un commentaire