passenger
Canvas LMS の起動に時間がかかりすぎて Passenger が落ちる
Canvas LMS というラーニングマネージメントシステムの運用中、Passenger が再起動を繰り返す症状になった。 何度か再起動を繰り返すと、たまに立ち上がる。
Canvas LMS は重量級のアプリケーションなので起動に時間がかかっている事が原因と仮定して 急場を凌ぐためサーバーの性能を上げると症状は解消した。
ただできれば安く運用したいため原因を調べ Passenger 側のタイムアウト値を伸ばすことで解消した。
環境
Ubuntu 18.04 Canvas LMS バージョン 2021/04/14 21:24:27 リリースのもの
原因
Apache の下記のようなログが出ていた。
[ E 2021-08-19 12:51:59.9818 2620/Tf age/Cor/App/Implementation.cpp:221 ]: Could not spawn process for application /var/canvas: A timeout occurred while starting a preloader process.
Error ID: 5601fca6
Error details saved to: /tmp/passenger-error-rBz6ES.html
Passenger は問題が起きた時 /tmp 配下にログを吐き出す。 /var/log/syslog ではなく絶えず吐き出すわけではないので問題を難しくしているようにも思うが。
# find / -name 'passenger-error*html'
/tmp/systemd-private-0af79b8b175f43b4a340f69608070e76-apache2.service-Ga9LrA/tmp/passenger-error-rmclOc.html
/tmp/systemd-private-0af79b8b175f43b4a340f69608070e76-apache2.service-Ga9LrA/tmp/passenger-error-rBz6ES.html
html をブラウザで見ると、[ What happened? ]、[How do I solve this ]、[Get help]、[Detailed diagnostics]があり、 [How do I solve this ]を見ると、
Maybe the server is currently so low on resources that all the work that needed to be done,
could not finish within the given time limit.
Please inspect the server resource utilization statistics in the diagnostics section to verify whether server is indeed low on resources.
If so, then either increase the spawn timeout (currently configured at 90 sec), or find a way to lower the server's resource utilization.
という表示が出ていた。素直に性能を上げたのは正しい、が、できれば安く運用したい。 spawn timeout を伸ばす方法も確認する。
対策
/etc/apache2/mods-enabled/passenger.conf に PassengerStartTimeout 300 を設定した。
Ubuntu 18.04 + Apache では下記に設定ファイルがあった。
/etc/apache2/mods-enabled/passenger.conf
下記のように PassengerStartTimeout 300
を追加した。
<IfModule mod_passenger.c>
PassengerRoot /usr/lib/ruby/vendor_ruby/phusion_passenger/locations.ini
PassengerDefaultRuby /usr/bin/passenger_free_ruby
PassengerStartTimeout 300
</IfModule>
参考
PassengerStartTimeout Passenger の出す html ファイルにもあったが、ここでもデフォルトが 90 秒であることが分かる。