Playを実装しました!アップデートでプリコンパイルするときのダウンタイムを回避するために、サーバーに 2 つの異なるインスタンス (%inst1 と %inst2 としましょう) を持つアプリ。ロードバランサーを取得するようにnginxを構成しました。インスタンスごとに独自のサブディレクトリがあり、ファイル application.conf を適切に構成して、%inst1 と %inst2 に異なるポートを取得します。nginx の設定ファイルはこんな感じです。
upstream myapp {
server localhost:9031;
server localhost:9032;
}
server {
server_name www.example.com;
access_log /var/log/nginx/myapp.access.log;
location / {
proxy_pass http://myapp;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
}
}
この構成を開発モードで試すと、完全に機能します。両方のインスタンスを実行し、更新のためにいずれかを停止すると、すべてのトラフィックがダウンタイムなしで他のインスタンスに移動します。アプリを再起動してnginxをリロードすると、両方のインスタンスが完全に機能します。
この問題は、インスタンスを本番モード用に構成したときに発生します。application.conf のみを次のように変更します。
%inst1.application.mode=dev
%inst2.application.mode=dev
に:
%inst1.application.mode=prod
%inst2.application.mode=prod
そして、両方のインスタンスを 2 回動作させることができません。2 番目のものを開始するたびに、502 Bad Gateway エラーが発生します。次に、最初のインスタンスのステータスを確認すると、次のエラーが表示されます。
$ play status --%inst1
~ _ _
~ _ __ | | __ _ _ _| |
~ | '_ \| |/ _' | || |_|
~ | __/|_|\____|\__ (_)
~ |_| |__/
~
~ play! 1.2.4, http://www.playframework.org
~ framework ID is inst1
~
~ Cannot contact the application...
~
また、次のようなエラーで起動できません。
Oops. /usr/share/apps/klingstore1 is already started! (or delete /usr/share/apps/klingstore1/server.pid)
それを止めることもありません:
Play was not running (Process id 11657 not found)
そして、server.pid を手動で削除する必要があります。その後、もう一度開始すると、他のインスタンスで再び発生します。
手がかりはありますか?
ありがとう!!
解決済み:
最後に、単に RAM の問題のようです。インスタンスは Play の同じ構成で正しく動作しています! 問題なくさまざまな日の間、Nginx。