Category Archives: Ruby on Rails

passenger-config and passenger-status result in an error on CentOS7

passenger-config and passenger-status result in an error on CentOS7.

CentOS Linux release 7.2.1511 (Core)
Apache/2.4.6 (CentOS)
Phusion Passenger 5.0.23 (Installed by `passenger-install-apache2-module`)

$ passenger-config restart-app
*** 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 one of:

 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 this command 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.


Passenger could not find instance registry directory (PassengerInstanceRegistryDir on Apache, passenger_instance_registry_dir on Nginx).

If instance registry directory is not explicitly specified, default value /tmp is used.
So instance registry dir is made in /tmp. But because Systemd PrivateTmp option is enabled on httpd (default), instance registry dir is created in httpd's private /tmp directory (/tmp/systemd-private-XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX-httpd.service-XXXXXX/tmp). This directory can't be found by other processes such as passenger-config or passenger-status.

This problem owes to Systemd's PrivateTmp, so it may also occurs on RHEL7 or Amazon Linux 2.

Workaround 1: Explicitly specify PassengerInstanceRegistryDir

This workaround remains Systemd's PrivateTmp enabled.
Explicitly specify Passenger's instance registry directory so that instance registry dir is not made in httpd's private /tmp directory.

First, I made PassengerInstanceRegistryDir to be created in /var/run, but since systemd-239 or later displays the following warning, I have modified it to be created in /run.

[/etc/tmpfiles.d/passenger.conf:1] Line references path below legacy directory /var/run/, updating /var/run/passenger-instreg → /run/passenger-instreg; please update the tmpfiles.d/ drop-in file accordingly.

Systemd logs warnings about the legacy tmpfile location /var/run - Red Hat Customer Portal

(on Apache)

PassengerInstanceRegistryDir /run/passenger-instreg

Because files and directories in /run is deleted on reboot, you must add config file in tmpfiles.d.
See man 5 tmpfiles.d for details.


D /run/passenger-instreg 0755 root root

You must add PASSENGER_INSTANCE_REGISTRY_DIR for the users who executes passenger-status and passenger-config.


export PASSENGER_INSTANCE_REGISTRY_DIR=/run/passenger-instreg

If you use capistrano-passenger, you must set PASSENGER_INSTANCE_REGISTRY_DIR in the stage's deploy recipe because capistrano-passenger executes `passenger-config restart-app`.

set :default_env, {
  "PASSENGER_INSTANCE_REGISTRY_DIR" => "/run/passenger-instreg"

Finally restart system.

Workaround 2: Disable PrivateTmp on httpd.service

This workaround disables Systemd's PrivateTmp on httpd.service.

$ sudo systemctl edit httpd.service

Then execute below.

$ sudo systemctl restart httpd.service

Manually copying files under /usr/lib/systemd/system/ is not recommended, so I fixed to use `systemctl edit`. Using `systemctl edit`, systemd configuration is automatically reloaded (in a way that is equivalent to daemon-reload).

Copy /usr/lib/systemd/system/httpd.service to /etc/systemd/system and edit it.



Then execute below.

$ sudo systemctl daemon-reload
$ sudo systemctl restart httpd.service

Source: CentOS 7 で Phusion Passenger の passenger-status を実行するとエラーとなる - Qiita
お前らもさっさとハマって泣くべきCentOS7の落とし穴4つ - Qiita
Handle systemd PrivateTmp #1475
Systemd入門(5) - PrivateTmpの実装を見る - めもめも

Redmine error when synchronizing repositories with Git

I executed Repository.fetch_changesets using script/runner by cron to synchronize repositories of Redline with Git and I got an error below.

git: not found

I modified redmine/lib/redmine/scm/adapters/git_adapter.rb like below and it became OK.

#GIT_BIN = "git"
GIT_BIN = "/usr/local/bin/git"
※ On r4795, r4797, you can set scm_git_command to the path to Git in configuration.yml, so you no longer need such modification like above.

I also encountered an onother problem.
When the user who executes Redmine does not have permission for the Git repository directory (like xxx.git), Redmine shows "The entry or revision was not found in the repository." error on repository page.

Workaround is:

$ sudo chmod o+rx xxxx.git
  • If the repository is in a user's home directory (e.g. on gitosis or gitolite), you also have to do chmod o+x for the user's home directory.

map(collect) method on an array of ActiveRecord object

Let's assume there is a model `Member` and the table `members` has a column `name`.

class Member < ActiveRecord::Base

You can use map (or collect) method as shown below.

members = Member.find(:all)
member_names =

This is thanks to the definition of Symbol#to_proc in ActiveSupport as shown below.

class Symbol
  def to_proc { |obj, *args| obj.send(self, *args) }

The code that uses map method above is equal to the code below.

members = Member.find(:all)
member_names = { |member| }