1
0

passenger-statusを実行するとERROR: Phusion Passenger doesn't seem to be running.が発生するときの解決方法

Posted at

導入

Phusion Passenger上で動作しているRuby on Railsアプリケーションでメモリリークが発生していると思われる事象が起きていた。
メモリリークの調査のために公式リファレンスに従ってpassenger-statusを実行しようとたところ以下のコードブロック内に記載したエラーが発生した。

$ passenger-status
ERROR: Phusion Passenger doesn't seem to be running. If you are sure that it is running, then the causes of this problem could be:

1. You customized the instance registry directory using Apache's PassengerInstanceRegistryDir option, Nginx's passenger_instance_registry_dir option, or Phusion Passenger Standalone's --instance-registry-dir command line argument. If so, please set the environment variable PASSENGER_INSTANCE_REGISTRY_DIR to that directory and run passenger-status again.
2. The instance directory has been removed by an operating system background service. Please set a different instance registry directory using Apache's PassengerInstanceRegistryDir option, Nginx's passenger_instance_registry_dir option, or Phusion Passenger Standalone's --instance-registry-dir command line argument.

メモリリークの調査以前にこちらのエラーの解消に時間がかかったので本記事で解消方法を整理する。

環境

Amazon Linux 2

$ passenger-config --version
Phusion Passenger 6.0.6

$ httpd -v
Server version: Apache/2.4.59 ()

公式には記載がないが以下の記事によればAmazon Linux 2はRHEL7/CentOS7をベースにしているらしい。

状況

まずは諸々の操作を行う前の状況について整理する。

/tmpの中には以下のようにsystemd-private-から始まるフォルダが存在する。

$ ls /tmp
systemd-private-xxxxxx-chronyd.service-xxxxxx
systemd-private-xxxxxx-httpd.service-xxxxxx

以下の記事によるとこれらのフォルダはCentOS系においてサービスの設定でPrivateTmp=trueにされていると作成される。PrivateTmp=trueにするとプロセスが使用する一時フォルダを隠蔽でき、セキュリティ的に安全になるらしい。

また今回の環境ではApacheの設定ファイルは/etc/httpd/conf/httpd.confである。

解決方法

基本的には以下の回答に記載の方法で解決した。以下の回答ではUbuntu 18.04 with Apache and Passenger v5+とされているためか今回の環境では微妙に変える必要があった。

具体的には以下の手順を行った。

$ sudo systemctl edit httpd.service

を実行するとエディターが開く。
エディターに

[Service]
PrivateTmp=false

を入力し/etc/systemd/system/httpd.service.d/override.confとして保存する。

変更を反映するために

$ sudo systemctl daemon-reload

を実行する。

systemctl daemon-reloadについては以下の記事を参考にした。

ちなみにsudoをつけなかったら下記のエラーが発生した。

$ systemctl daemon-reload
Warning: httpd.service changed on disk. Run 'systemctl daemon-reload' to reload units.

念のためhttpdをリスタートする。

$ sudo systemctl restart httpd

これで完了。passenger-statusが正常に動作した。

うまくいかなかった方法

httpd.confPassengerInstanceRegistryDir /tmpを追記したりPASSENGER_TMPDIR=/tmp passenger-statusを実行したりしたがこれらでは解消されなかった。これらの方法は以下の記事に記載されているものである。

※今回の状況ではうまくいかなかっただけであり、記事を批判する意図はないことを注意する。以下の記事に記載の方法でもうまくいくケースはあると思われる。

1
0
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
1
0