Tuesday, February 18, 2014

Redmine Error: Phusion Passenger Watchdog Failed to Start

Having upgraded a few package including Redmine and Ruby on Rail, my redmine host failed to start. I am running a Apache web server for the Redmine. When I browse the Redmine host, the error message returned in the web browser is


Application error
Rails application failed to start properly

The Redmine's production log at the redmine/log directory indicates nothing is generated in the log, which means Redmine does not even run. To verify that Redmine itself is actually OK, run it from the command line,

ruby script/rails server webrick -e production

Then point the browser to http://localhost:3000/. The Redmine server runs OK. Checking Apache's error log (the error_log file) a little bit closely, the error message looks the following,

[pid=9135 thr=140212503205888 file=ext/common/LoggingAgent/Main.cpp:287 
time=2014-02-01 03:29:02.699 ]: *** ERROR: Cannot stat 
'/var/log/passenger-analytics': Permission denied (13)
     (empty)
[Sun Feb 01 03:29:02 2014] [error] *** Passenger could not be initialized 
because of this error: Unable to start the Phusion Passenger watchdog 
because it encountered the following error during startup: Unable to start 
the Phusion Passenger logging agent: it seems to have crashed during startup 
for an unknown reason, with exit code 1
At the same time, the redmine_error.log that belongs to the virtual host in which the Redmine runs shows something similar to,

[Mon Feb 01 22:55:15 2014] [warn] [client 10.0.0.1] (104)Connection reset by peer: mod_fcgid: 
 error reading data from FastCGI server
[Mon Feb 01 22:55:15 2014] [error] [client 10.0.0.1] Premature end of script headers: 
 dispatch.fcgi

Now it becomes clearer that the problem may be that Phusion Passenger cannot access the directory /var/log/passenger-analytics. After I give sufficient permission to the directory as follows, the Phusion Passenger starts OK and the Redmine runs normally.

chown -R apache:apache passenger-analytics
chmod -R 750 apache:apache passenger-analytics
chcon system_u:object_r:httpd_sys_content_t:s0  passenger-analytics

The last step is necessary since SeLinux is enabled in my case. A second, perhaps a better approach is to route any analytics logs to Redmine's log directory, for which, I added the following line to the Redmine's Apache configuration file, in my case /etc/httpd/conf.d/redmine.conf,


<VirtualHost *:80>
   ......
   PassengerAnalyticsLogDir REDMINE_ROOT/log
   ......
</VirtualHost> 

In the above, replacing REDMINE_ROOT by the root directory of the Redmine installation, such as /home/usr/redmine etc. In this case, there is not need to change the directory permission and ownership since the Redmine directory should already have had correct permission and SeLinux context. In addition, you can consolidate the log files in a place that you like.

3 comments: