74
68

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

foreverコマンドでNodeJSアプリを起動したままにする

Posted at

NodeJsアプリをデーモン化する

利点:"node app.js"をやらなくていい

npmでforeverを入れる

npm install -g forever

foreverコマンドの使い方

起動

forever start app.js

停止

forever stop app.js

再起動

forever restart app.js

foreverで実行しているリスト

forever list

こんなのが出る

info:    Forever processes running
data:        uid  command       script forever pid   id logfile                 uptime
data:    [0] ioGt /usr/bin/node app.js 39066   39068    /root/.forever/ioGt.log 0:0:0:13.174

ログ

forever logs

結果

info:    Logs for running Forever processes
data:        script logfile
data:    [0] app.js /root/.forever/ioGt.log

設定確認

forever config

結果

data:    {
data:      root: '/root/.forever',
data:      pidPath: '/root/.forever/pids',
data:      sockPath: '/root/.forever/sock',
data:      loglength: 100,
data:      logstream: false,
data:      columns: [
data:          'uid',
data:          'command',
data:          'script',
data:          'forever',
data:          'pid',
data:          'id',
data:          'logfile',
data:          'uptime'
data:      ]
data:    }

まとめ

foreverコマンドはstartしたらずっと動いてるので、便利。
便利だけど、ずっと動いてるので使い方忘れそう。
オプションもあるから、使えそうなら使ってみる。

74
68
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
74
68

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?