目的
自前でParse Serverを運用しているが、変なクエリでAPI叩くとすぐ落ちるので自動で再起動したい。
Parse Serverのconfigを変更するとParse Serverが再起動して適用されるようにしたい。
手早くParse Serverのインスタンスを追加したい。
モニタリングしたい。
事前準備
npm install -g parse-server parse-dashboard pm2
configのサンプル
使い方
parse-configs/parse_example.json
を参考にして、キーなどを設定したjsonを作る。
参考: https://github.com/parse-community/parse-server#configuration
parse-dashboard-config.json
を書き換える。
参考: https://github.com/parse-community/parse-dashboard
pm2_config.json
を書き換える。
参考: http://pm2.keymetrics.io/docs/usage/application-declaration/
"watch_options": {
"usePolling": true
}
をしないと、parse-configs/parse_example.json
のようにディレクトリの中にあるようなファイルをwatchできない?
parse-dashboard-config.json
はusePolling: false
でもwatchできる。
起動とかのよく使うコマンド
pm2 start pm2_config.json
pm2 delete all
pm2 restart all
pm2 kill
MongoDB
pm2でMongoDBもモニタリングしたければ、
pm2 install pm2-mongodb
参考: https://github.com/pm2-hive/pm2-mongodb
MongoDBのポートなどがデフォルトなら何も設定しなくてもいい。