2014年7月14日月曜日

バックグラウンドで動かす

今までテストでファオグランドで node.js を実行していました。

バックグラウンドで実行したいな~と思い、
単純にバックグラウンド実行用にコマンドの後ろに&をつけてやってみましたがうまくいかず(; ・`д・´) ナ、ナンダッテー!! (`・д´・ ;)

調べてみると、forever という node.js 用のデーモンマネージャーがあるそうです(゚∀゚)キタコレ!!

forever は npm を使ってインストールできるのでそちらからインストールを行います。

-gオプションをつけてグローバルインストールする(npm 1.0系の場合?)
# npm install forever -g
npm http GET https://registry.npmjs.org/forever
npm http 200 https://registry.npmjs.org/forever
npm http GET https://registry.npmjs.org/forever/-/forever-0.11.1.tgz
npm http 200 https://registry.npmjs.org/forever/-/forever-0.11.1.tgz
npm http GET https://registry.npmjs.org/flatiron
npm http GET https://registry.npmjs.org/colors
npm http GET https://registry.npmjs.org/cliff
npm http GET https://registry.npmjs.org/forever-monitor
npm http GET https://registry.npmjs.org/nconf
npm http GET https://registry.npmjs.org/nssocket
npm http GET https://registry.npmjs.org/pkginfo
npm http GET https://registry.npmjs.org/timespan
npm http GET https://registry.npmjs.org/watch
npm http GET https://registry.npmjs.org/utile
npm http GET https://registry.npmjs.org/winston
npm http GET https://registry.npmjs.org/optimist
npm http 200 https://registry.npmjs.org/colors
npm http GET https://registry.npmjs.org/colors/-/colors-0.6.2.tgz
npm http 200 https://registry.npmjs.org/cliff
npm http GET https://registry.npmjs.org/cliff/-/cliff-0.1.8.tgz
npm http 200 https://registry.npmjs.org/pkginfo
npm http GET https://registry.npmjs.org/pkginfo/-/pkginfo-0.3.0.tgz
npm http 200 https://registry.npmjs.org/timespan
npm http GET https://registry.npmjs.org/timespan/-/timespan-2.3.0.tgz
npm http 200 https://registry.npmjs.org/colors/-/colors-0.6.2.tgz
npm http 200 https://registry.npmjs.org/cliff/-/cliff-0.1.8.tgz
npm http 200 https://registry.npmjs.org/pkginfo/-/pkginfo-0.3.0.tgz
npm http 200 https://registry.npmjs.org/timespan/-/timespan-2.3.0.tgz
npm http 200 https://registry.npmjs.org/forever-monitor
npm http GET https://registry.npmjs.org/forever-monitor/-/forever-monitor-1.2.3.tgz
npm http 200 https://registry.npmjs.org/watch
npm http GET https://registry.npmjs.org/watch/-/watch-0.8.0.tgz
npm http 200 https://registry.npmjs.org/flatiron
npm http GET https://registry.npmjs.org/flatiron/-/flatiron-0.3.11.tgz
npm http 304 https://registry.npmjs.org/optimist
npm http GET https://registry.npmjs.org/optimist/-/optimist-0.6.1.tgz
npm http 200 https://registry.npmjs.org/nconf
npm http 200 https://registry.npmjs.org/forever-monitor/-/forever-monitor-1.2.3.tgz
npm http GET https://registry.npmjs.org/nconf/-/nconf-0.6.9.tgz
npm http 200 https://registry.npmjs.org/utile
npm http GET https://registry.npmjs.org/utile/-/utile-0.2.1.tgz
npm http 200 https://registry.npmjs.org/nconf/-/nconf-0.6.9.tgz
npm http 200 https://registry.npmjs.org/watch/-/watch-0.8.0.tgz
npm http 200 https://registry.npmjs.org/utile/-/utile-0.2.1.tgz
npm http 200 https://registry.npmjs.org/flatiron/-/flatiron-0.3.11.tgz
npm http 200 https://registry.npmjs.org/nssocket
npm http GET https://registry.npmjs.org/nssocket/-/nssocket-0.5.1.tgz
npm http 200 https://registry.npmjs.org/optimist/-/optimist-0.6.1.tgz
npm http 200 https://registry.npmjs.org/winston
npm http GET https://registry.npmjs.org/winston/-/winston-0.7.3.tgz
npm http 200 https://registry.npmjs.org/nssocket/-/nssocket-0.5.1.tgz
npm http 200 https://registry.npmjs.org/winston/-/winston-0.7.3.tgz
npm http GET https://registry.npmjs.org/eventemitter2
npm http GET https://registry.npmjs.org/lazy
npm http GET https://registry.npmjs.org/deep-equal
npm http GET https://registry.npmjs.org/i
npm http GET https://registry.npmjs.org/ncp
npm http GET https://registry.npmjs.org/rimraf
npm http GET https://registry.npmjs.org/mkdirp
npm http GET https://registry.npmjs.org/async
npm http GET https://registry.npmjs.org/minimist
npm http GET https://registry.npmjs.org/wordwrap
npm http GET https://registry.npmjs.org/broadway
npm http GET https://registry.npmjs.org/broadway
npm http GET https://registry.npmjs.org/prompt
npm http GET https://registry.npmjs.org/ps-tree
npm http GET https://registry.npmjs.org/director
npm http 200 https://registry.npmjs.org/deep-equal
npm http 200 https://registry.npmjs.org/i
npm http GET https://registry.npmjs.org/minimatch
npm http 200 https://registry.npmjs.org/ncp
npm http GET https://registry.npmjs.org/optimist/-/optimist-0.6.0.tgz
npm http GET https://registry.npmjs.org/watch/-/watch-0.5.1.tgz
npm http GET https://registry.npmjs.org/utile/-/utile-0.1.7.tgz
npm http GET https://registry.npmjs.org/deep-equal/-/deep-equal-0.2.1.tgz
npm http GET https://registry.npmjs.org/i/-/i-0.3.2.tgz
npm http 304 https://registry.npmjs.org/mkdirp
npm http GET https://registry.npmjs.org/ncp/-/ncp-0.4.2.tgz
npm http GET https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.0.tgz
npm http 200 https://registry.npmjs.org/eventemitter2
npm http GET https://registry.npmjs.org/eventemitter2/-/eventemitter2-0.4.14.tgz
npm http 200 https://registry.npmjs.org/rimraf
npm http GET https://registry.npmjs.org/eyes
npm http 304 https://registry.npmjs.org/wordwrap
npm http GET https://registry.npmjs.org/winston/-/winston-0.6.2.tgz
npm http GET https://registry.npmjs.org/rimraf/-/rimraf-2.2.8.tgz
npm http 200 https://registry.npmjs.org/minimist
npm http GET https://registry.npmjs.org/minimist/-/minimist-0.0.10.tgz
npm http GET https://registry.npmjs.org/cycle
npm http GET https://registry.npmjs.org/request
npm http GET https://registry.npmjs.org/stack-trace
npm http GET https://registry.npmjs.org/async
npm http 200 https://registry.npmjs.org/lazy
npm http GET https://registry.npmjs.org/lazy/-/lazy-1.0.11.tgz
npm http 200 https://registry.npmjs.org/async
npm http 200 https://registry.npmjs.org/deep-equal/-/deep-equal-0.2.1.tgz
npm http 200 https://registry.npmjs.org/utile/-/utile-0.1.7.tgz
npm http 200 https://registry.npmjs.org/watch/-/watch-0.5.1.tgz
npm http GET https://registry.npmjs.org/ini
npm http 200 https://registry.npmjs.org/optimist/-/optimist-0.6.0.tgz
npm http 200 https://registry.npmjs.org/ncp/-/ncp-0.4.2.tgz
npm http 200 https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.0.tgz
npm http GET https://registry.npmjs.org/async/-/async-0.2.9.tgz
npm http 200 https://registry.npmjs.org/i/-/i-0.3.2.tgz
npm http 200 https://registry.npmjs.org/eventemitter2/-/eventemitter2-0.4.14.tgz
npm http 200 https://registry.npmjs.org/winston/-/winston-0.6.2.tgz
npm http 200 https://registry.npmjs.org/minimist/-/minimist-0.0.10.tgz
npm http 200 https://registry.npmjs.org/rimraf/-/rimraf-2.2.8.tgz
npm http 200 https://registry.npmjs.org/lazy/-/lazy-1.0.11.tgz
npm http 200 https://registry.npmjs.org/async/-/async-0.2.9.tgz
npm http 200 https://registry.npmjs.org/prompt
npm http 200 https://registry.npmjs.org/ps-tree
npm http GET https://registry.npmjs.org/prompt/-/prompt-0.2.11.tgz
npm http GET https://registry.npmjs.org/ps-tree/-/ps-tree-0.0.3.tgz
npm http 304 https://registry.npmjs.org/minimatch
npm http GET https://registry.npmjs.org/minimatch/-/minimatch-0.2.14.tgz
npm http 200 https://registry.npmjs.org/eyes
npm http GET https://registry.npmjs.org/eyes/-/eyes-0.1.8.tgz
npm http 200 https://registry.npmjs.org/broadway
npm http 200 https://registry.npmjs.org/cycle
npm http 200 https://registry.npmjs.org/director
npm http GET https://registry.npmjs.org/broadway/-/broadway-0.2.9.tgz
npm http GET https://registry.npmjs.org/cycle/-/cycle-1.0.3.tgz
npm http GET https://registry.npmjs.org/director/-/director-1.1.10.tgz
npm http 200 https://registry.npmjs.org/broadway
npm http 200 https://registry.npmjs.org/stack-trace
npm http GET https://registry.npmjs.org/stack-trace/-/stack-trace-0.0.9.tgz
npm http 200 https://registry.npmjs.org/minimatch/-/minimatch-0.2.14.tgz
npm http 200 https://registry.npmjs.org/ps-tree/-/ps-tree-0.0.3.tgz
npm http 200 https://registry.npmjs.org/ini
npm http 200 https://registry.npmjs.org/prompt/-/prompt-0.2.11.tgz
npm http 200 https://registry.npmjs.org/broadway/-/broadway-0.2.9.tgz
npm http GET https://registry.npmjs.org/ini/-/ini-1.2.1.tgz
npm http 200 https://registry.npmjs.org/cycle/-/cycle-1.0.3.tgz
npm http 200 https://registry.npmjs.org/eyes/-/eyes-0.1.8.tgz
npm http 200 https://registry.npmjs.org/director/-/director-1.1.10.tgz
npm http 200 https://registry.npmjs.org/stack-trace/-/stack-trace-0.0.9.tgz
npm http 200 https://registry.npmjs.org/ini/-/ini-1.2.1.tgz
npm http 200 https://registry.npmjs.org/request
npm http 200 https://registry.npmjs.org/async
npm http GET https://registry.npmjs.org/request/-/request-2.16.6.tgz
npm http 200 https://registry.npmjs.org/request/-/request-2.16.6.tgz
npm http GET https://registry.npmjs.org/minimist/-/minimist-0.0.8.tgz
npm http 200 https://registry.npmjs.org/minimist/-/minimist-0.0.8.tgz
npm http GET https://registry.npmjs.org/event-stream
npm http GET https://registry.npmjs.org/lru-cache
npm http GET https://registry.npmjs.org/sigmund
npm http GET https://registry.npmjs.org/async/-/async-0.1.22.tgz
npm http GET https://registry.npmjs.org/ncp/-/ncp-0.2.7.tgz
npm http GET https://registry.npmjs.org/rimraf/-/rimraf-1.0.9.tgz
npm http 304 https://registry.npmjs.org/lru-cache
npm http 304 https://registry.npmjs.org/sigmund
npm http 200 https://registry.npmjs.org/event-stream
npm http GET https://registry.npmjs.org/event-stream/-/event-stream-0.5.3.tgz
npm http 200 https://registry.npmjs.org/async/-/async-0.1.22.tgz
npm http 200 https://registry.npmjs.org/ncp/-/ncp-0.2.7.tgz
npm http 200 https://registry.npmjs.org/rimraf/-/rimraf-1.0.9.tgz
npm http 200 https://registry.npmjs.org/event-stream/-/event-stream-0.5.3.tgz
npm http GET https://registry.npmjs.org/eventemitter2/-/eventemitter2-0.4.12.tgz
npm http GET https://registry.npmjs.org/winston/-/winston-0.7.2.tgz
npm http 200 https://registry.npmjs.org/eventemitter2/-/eventemitter2-0.4.12.tgz
npm http 200 https://registry.npmjs.org/winston/-/winston-0.7.2.tgz
npm http GET https://registry.npmjs.org/read
npm http GET https://registry.npmjs.org/revalidator
npm http GET https://registry.npmjs.org/optimist/-/optimist-0.2.8.tgz
npm http 200 https://registry.npmjs.org/read
npm http 200 https://registry.npmjs.org/revalidator
npm http GET https://registry.npmjs.org/request/-/request-2.9.203.tgz
npm http GET https://registry.npmjs.org/pkginfo/-/pkginfo-0.2.3.tgz
npm http GET https://registry.npmjs.org/read/-/read-1.0.5.tgz
npm http GET https://registry.npmjs.org/revalidator/-/revalidator-0.1.8.tgz
npm http 200 https://registry.npmjs.org/optimist/-/optimist-0.2.8.tgz
npm http 200 https://registry.npmjs.org/revalidator/-/revalidator-0.1.8.tgz
npm http 200 https://registry.npmjs.org/request/-/request-2.9.203.tgz
npm http GET https://registry.npmjs.org/form-data
npm http GET https://registry.npmjs.org/hawk
npm http GET https://registry.npmjs.org/node-uuid
npm http GET https://registry.npmjs.org/cookie-jar
npm http 200 https://registry.npmjs.org/read/-/read-1.0.5.tgz
npm http GET https://registry.npmjs.org/aws-sign
npm http GET https://registry.npmjs.org/oauth-sign
npm http GET https://registry.npmjs.org/forever-agent
npm http GET https://registry.npmjs.org/tunnel-agent
npm http 200 https://registry.npmjs.org/pkginfo/-/pkginfo-0.2.3.tgz
npm http GET https://registry.npmjs.org/json-stringify-safe
npm http GET https://registry.npmjs.org/mime
npm http GET https://registry.npmjs.org/qs
npm http 200 https://registry.npmjs.org/cookie-jar
npm http 200 https://registry.npmjs.org/aws-sign
npm http GET https://registry.npmjs.org/cookie-jar/-/cookie-jar-0.2.0.tgz
npm http GET https://registry.npmjs.org/aws-sign/-/aws-sign-0.2.0.tgz
npm http 200 https://registry.npmjs.org/oauth-sign
npm http 200 https://registry.npmjs.org/form-data
npm http 200 https://registry.npmjs.org/forever-agent
npm http 200 https://registry.npmjs.org/tunnel-agent
npm http GET https://registry.npmjs.org/oauth-sign/-/oauth-sign-0.2.0.tgz
npm http 200 https://registry.npmjs.org/node-uuid
npm http GET https://registry.npmjs.org/form-data/-/form-data-0.0.10.tgz
npm http 304 https://registry.npmjs.org/mime
npm http GET https://registry.npmjs.org/forever-agent/-/forever-agent-0.2.0.tgz
npm http GET https://registry.npmjs.org/tunnel-agent/-/tunnel-agent-0.2.0.tgz
npm http 200 https://registry.npmjs.org/hawk
npm http 304 https://registry.npmjs.org/qs
npm http 200 https://registry.npmjs.org/json-stringify-safe
npm http GET https://registry.npmjs.org/node-uuid/-/node-uuid-1.4.1.tgz
npm http 200 https://registry.npmjs.org/cookie-jar/-/cookie-jar-0.2.0.tgz
npm http 200 https://registry.npmjs.org/aws-sign/-/aws-sign-0.2.0.tgz
npm http GET https://registry.npmjs.org/hawk/-/hawk-0.10.2.tgz
npm http 200 https://registry.npmjs.org/tunnel-agent/-/tunnel-agent-0.2.0.tgz
npm http GET https://registry.npmjs.org/qs/-/qs-0.5.6.tgz
npm http 200 https://registry.npmjs.org/oauth-sign/-/oauth-sign-0.2.0.tgz
npm http GET https://registry.npmjs.org/json-stringify-safe/-/json-stringify-safe-3.0.0.tgz
npm http 200 https://registry.npmjs.org/node-uuid/-/node-uuid-1.4.1.tgz
npm http 200 https://registry.npmjs.org/form-data/-/form-data-0.0.10.tgz
npm http 200 https://registry.npmjs.org/forever-agent/-/forever-agent-0.2.0.tgz
npm http 200 https://registry.npmjs.org/qs/-/qs-0.5.6.tgz
npm http 200 https://registry.npmjs.org/hawk/-/hawk-0.10.2.tgz
npm http 200 https://registry.npmjs.org/json-stringify-safe/-/json-stringify-safe-3.0.0.tgz
npm http GET https://registry.npmjs.org/mute-stream
npm http 200 https://registry.npmjs.org/mute-stream
npm http GET https://registry.npmjs.org/mute-stream/-/mute-stream-0.0.4.tgz
npm http 200 https://registry.npmjs.org/mute-stream/-/mute-stream-0.0.4.tgz
npm WARN engine hawk@0.10.2: wanted: {"node":"0.8.x"} (current: {"node":"v0.10.28","npm":"1.4.9"})
npm http GET https://registry.npmjs.org/combined-stream
npm http 200 https://registry.npmjs.org/combined-stream
npm http GET https://registry.npmjs.org/combined-stream/-/combined-stream-0.0.5.tgz
npm http 200 https://registry.npmjs.org/combined-stream/-/combined-stream-0.0.5.tgz
npm WARN engine hawk@0.10.2: wanted: {"node":"0.8.x"} (current: {"node":"v0.10.28","npm":"1.4.9"})
npm http GET https://registry.npmjs.org/cryptiles
npm http GET https://registry.npmjs.org/hoek
npm http GET https://registry.npmjs.org/boom
npm http GET https://registry.npmjs.org/sntp
npm http GET https://registry.npmjs.org/delayed-stream
npm http 200 https://registry.npmjs.org/sntp
npm http GET https://registry.npmjs.org/sntp/-/sntp-0.1.4.tgz
npm http 200 https://registry.npmjs.org/cryptiles
npm http GET https://registry.npmjs.org/cryptiles/-/cryptiles-0.1.3.tgz
npm http 200 https://registry.npmjs.org/boom
npm http GET https://registry.npmjs.org/boom/-/boom-0.3.8.tgz
npm http 200 https://registry.npmjs.org/hoek
npm http 200 https://registry.npmjs.org/sntp/-/sntp-0.1.4.tgz
npm http GET https://registry.npmjs.org/hoek/-/hoek-0.7.6.tgz
npm http 200 https://registry.npmjs.org/cryptiles/-/cryptiles-0.1.3.tgz
npm http 200 https://registry.npmjs.org/delayed-stream
npm http GET https://registry.npmjs.org/delayed-stream/-/delayed-stream-0.0.5.tgz
npm http 200 https://registry.npmjs.org/boom/-/boom-0.3.8.tgz
npm http 200 https://registry.npmjs.org/hoek/-/hoek-0.7.6.tgz
npm http 200 https://registry.npmjs.org/delayed-stream/-/delayed-stream-0.0.5.tgz
npm WARN engine hawk@0.10.2: wanted: {"node":"0.8.x"} (current: {"node":"v0.10.28","npm":"1.4.9"})
npm WARN engine cryptiles@0.1.3: wanted: {"node":"0.8.x"} (current: {"node":"v0.10.28","npm":"1.4.9"})
npm WARN engine sntp@0.1.4: wanted: {"node":"0.8.x"} (current: {"node":"v0.10.28","npm":"1.4.9"})
npm WARN engine boom@0.3.8: wanted: {"node":"0.8.x"} (current: {"node":"v0.10.28","npm":"1.4.9"})
npm WARN engine hoek@0.7.6: wanted: {"node":"0.8.x"} (current: {"node":"v0.10.28","npm":"1.4.9"})
npm WARN engine boom@0.3.8: wanted: {"node":"0.8.x"} (current: {"node":"v0.10.28","npm":"1.4.9"})
npm WARN engine cryptiles@0.1.3: wanted: {"node":"0.8.x"} (current: {"node":"v0.10.28","npm":"1.4.9"})
npm WARN engine sntp@0.1.4: wanted: {"node":"0.8.x"} (current: {"node":"v0.10.28","npm":"1.4.9"})
npm WARN engine hoek@0.7.6: wanted: {"node":"0.8.x"} (current: {"node":"v0.10.28","npm":"1.4.9"})
npm WARN engine hoek@0.7.6: wanted: {"node":"0.8.x"} (current: {"node":"v0.10.28","npm":"1.4.9"})
npm WARN engine boom@0.3.8: wanted: {"node":"0.8.x"} (current: {"node":"v0.10.28","npm":"1.4.9"})
npm WARN engine cryptiles@0.1.3: wanted: {"node":"0.8.x"} (current: {"node":"v0.10.28","npm":"1.4.9"})
npm WARN engine sntp@0.1.4: wanted: {"node":"0.8.x"} (current: {"node":"v0.10.28","npm":"1.4.9"})
/root/.nvm/v0.10.28/bin/forever -> /root/.nvm/v0.10.28/lib/node_modules/forever/bin/forever
/root/.nvm/v0.10.28/bin/foreverd -> /root/.nvm/v0.10.28/lib/node_modules/forever/bin/foreverd
forever@0.11.1 /root/.nvm/v0.10.28/lib/node_modules/forever
tqq watch@0.8.0
tqq colors@0.6.2
tqq pkginfo@0.3.0
tqq timespan@2.3.0
tqq optimist@0.6.1 (wordwrap@0.0.2, minimist@0.0.10)
tqq nssocket@0.5.1 (eventemitter2@0.4.14, lazy@1.0.11)
tqq utile@0.2.1 (deep-equal@0.2.1, rimraf@2.2.8, ncp@0.4.2, async@0.2.10, i@0.3.2, mkdirp@0.5.0)
tqq nconf@0.6.9 (ini@1.2.1, async@0.2.9, optimist@0.6.0)
tqq cliff@0.1.8 (eyes@0.1.8, winston@0.6.2)
tqq winston@0.7.3 (cycle@1.0.3, stack-trace@0.0.9, eyes@0.1.8, async@0.2.10, request@2.16.6)
tqq forever-monitor@1.2.3 (watch@0.5.1, minimatch@0.2.14, utile@0.1.7, ps-tree@0.0.3, broadway@0.2.9)
mqq flatiron@0.3.11 (optimist@0.6.0, director@1.1.10, prompt@0.2.11, broadway@0.2.9)
アプリケーションの起動では forever コマンドを利用して起動させます。

アプリケーションの起動
forever start node-chat-demo/app.js
アプリケーションの起動確認
# forever list
info:    Forever processes running
data:        uid  command                      script                forever pid   logfile                 uptime
data:    [0] qigP /root/.nvm/v0.10.28/bin/node node-chat-demo/app.js 21456   21458 /root/.forever/qigP.log 0:0:0:52.274
キタ――(゚∀゚)――!!

forever list で表示されたリストの[]で囲まれた数値がプロセス番号になります。
このプロセス番号を利用して、アプリケーションの停止を行います(´・∀・`)ヘー

アプリケーションの終了(forever stop プロセス番号)
# forever stop 0
info:    Forever stopped process:
data:        uid  command                      script                forever pid   logfile                 uptime
[0] qigP /root/.nvm/v0.10.28/bin/node node-chat-demo/app.js 21456   21458 /root/.forever/qigP.log 0:0:4:9.573
停止後に、アプリケーションの起動確認
# forever list
info:    No forever processes running
foreverコマンドのオプション確認
# 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:      columns reset       Resets all columns to defaults 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
           (foevert本体のログ)
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)
           実行するコマンド(デフォルトは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
           (stdout/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:      --killSignal     Support exit signal customization (default is SIGKILL)
help:                       used for restarting script gracefully eg. --killSignal=SIGTERM
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 start app.js

#ログファイルを出力する
forever start -a -l /tmp/node.forever.log -o /tmp/node.out.log -e /tmp/node.error.log app.js

#NODE_ENVを利用して実行モードを変更する
NODE_ENV=developer forever start -a -l /tmp/node.forever.log -o /tmp/node.out.log -e /tmp/node.error.log app.js

#実行中のアプリ一覧を表示
forever list

#指定したアプリのみ停止
forever stop プロセスID

#全てのアプリを停止
forever stopall

#再起動
forever restart

#全てのプロセスを再起動
forever restartall

以上です(`・ω・´)ゞビシッ!!

参考URL

0 件のコメント:

コメントを投稿