接下來(lái),就讓我們看看forever能不能實(shí)現(xiàn)目標(biāo)。
一、forever介紹
forever是一個(gè)簡(jiǎn)單的命令式nodejs的守護(hù)進(jìn)程,能夠啟動(dòng),停止,重啟App應(yīng)用。forever完全基于命令行操作,在forever進(jìn)程之下,創(chuàng)建node的子進(jìn)程,通過(guò)monitor監(jiān)控node子進(jìn)程的運(yùn)行情況,一旦文件更新,或者進(jìn)程掛掉,forever會(huì)自動(dòng)重啟node服務(wù)器,確保應(yīng)用正常運(yùn)行。
二、 forever安裝
全局安裝forever
~ D:/workspace/javascript>npm install -g forever
D:/toolkit/nodejs/forever -> D:/toolkit/nodejs/node_modules/forever/bin/forever
D:/toolkit/nodejs/foreverd -> D:/toolkit/nodejs/node_modules/forever/bin/foreverd
查看forever幫助
~ D:/workspace/javascript>forever -h
help: usage: forever [action] [options] SCRIPT [script-options]
help:
help: Monitors the script specified in the current process or as a daemon
help:
help: actions:
help: start Start SCRIPT as a daemon
help: stop Stop the daemon SCRIPT
help: stopall Stop all running forever scripts
help: restart Restart the daemon SCRIPT
help: restartall Restart all running forever scripts
help: list List all running forever scripts
help: config Lists all forever user configuration
help: set <key> <val> Sets the specified forever config <key>
help: clear <key> Clears the specified forever config <key>
help: logs Lists log files for all forever processes
help: logs <script|index> Tails the logs for <script|index>
help: columns add <col> Adds the specified column to the output in `forever list`
help: columns rm <col> Removed the specified column from the output in `forever list`
help: columns set <cols> Set all columns for the output in `forever list`
help: cleanlogs [CAREFUL] Deletes all historical forever log files
help:
help: options:
help: -m MAX Only run the specified script MAX times
help: -l LOGFILE Logs the forever output to LOGFILE
help: -o OUTFILE Logs stdout from child script to OUTFILE
help: -e ERRFILE Logs stderr from child script to ERRFILE
help: -p PATH Base path for all forever related files (pid files, etc.)
help: -c COMMAND COMMAND to execute (defaults to node)
help: -a, --append Append logs
help: -f, --fifo Stream logs to stdout
help: -n, --number Number of log lines to print
help: --pidFile The pid file
help: --sourceDir The source directory for which SCRIPT is relative to
help: --minUptime Minimum uptime (millis) for a script to not be considered "spinning"
help: --spinSleepTime Time to wait (millis) between launches of a spinning script.
help: --colors --no-colors will disable output coloring
help: --plain alias of --no-colors
help: -d, --debug Forces forever to log debug output
help: -v, --verbose Turns on the verbose messages from Forever
help: -s, --silent Run the child script silencing stdout and stderr
help: -w, --watch Watch for file changes
help: --watchDirectory Top-level directory to watch from
help: --watchIgnore To ignore pattern when watch is enabled (multiple option is allowed)
help: -h, --help You're staring at it
help:
help: [Long Running Process]
help: The forever process will continue to run outputting log messages to the console.
help: ex. forever -o out.log -e err.log my-script.js
help:
help: [Daemon]
help: The forever process will run as a daemon which will make the target process start
help: in the background. This is extremely useful for remote starting simple node.js scripts
help: without using nohup. It is recommended to run start with -o -l, & -e.
help: ex. forever start -l forever.log -o out.log -e err.log my-daemon.js
help: forever stop my-daemon.js
help:
我們看到forever支持的命令和配置項(xiàng)確實(shí)不少,應(yīng)該是偏命令行的管理工具。
三、forever命令行的中文解釋
子命令actions:
start:啟動(dòng)守護(hù)進(jìn)程
stop:停止守護(hù)進(jìn)程
stopall:停止所有的forever進(jìn)程
restart:重啟守護(hù)進(jìn)程
restartall:重啟所有的foever進(jìn)程
list:列表顯示forever進(jìn)程
config:列出所有的用戶配置項(xiàng)
set <key> <val>: 設(shè)置用戶配置項(xiàng)
clear <key>: 清楚用戶配置項(xiàng)
logs: 列出所有forever進(jìn)程的日志
logs <script|index>: 顯示最新的日志
columns add <col>: 自定義指標(biāo)到forever list
columns rm <col>: 刪除forever list的指標(biāo)
columns set<cols>: 設(shè)置所有的指標(biāo)到forever list
cleanlogs: 刪除所有的forever歷史日志
配置參數(shù)options:
-m MAX: 運(yùn)行指定腳本的次數(shù)
-l LOGFILE: 輸出日志到LOGFILE
-o OUTFILE: 輸出控制臺(tái)信息到OUTFILE
-e ERRFILE: 輸出控制臺(tái)錯(cuò)誤在ERRFILE
-p PATH: 根目錄
-c COMMAND: 執(zhí)行命令,默認(rèn)是node
-a,
主站蜘蛛池模板:
鞍山市|
长海县|
辉南县|
满洲里市|
三明市|
海阳市|
萝北县|
长乐市|
商城县|
横山县|
伊宁市|
香港
|
阳江市|
安康市|
鄢陵县|
儋州市|
聂拉木县|
麻阳|
措勤县|
安多县|
荔波县|
通化县|
娄底市|
娱乐|
黄浦区|
石景山区|
镇远县|
团风县|
镇巴县|
营口市|
新昌县|
温泉县|
馆陶县|
崇左市|
台中县|
郧西县|
阿拉善盟|
分宜县|
武冈市|
探索|
焉耆|