Welcome Guest | Login

Subdomain Rails Application Error

Hi,

I have two rails apps running. My first is my main app and I have my public_html folder symlinked to the public folder for this application. My second app is served as a subdomain and I have a symlink in public_html (so actually a symlink in the public folder of my first app) pointing to my second app's public folder and named after my second application and I have set up the subdomain in cPanel.

My trouble is that I am getting "Application error Rails application failed to start properly" thrown out by the .htaccess file of my second app. I know this much because I have edited each of my .htaccess 500 error messages so that I can distinguish them.

If I run
ruby dispatch.fcgi
in my second app's public folder I get an html page back on the command line and all looks fine.

So my question is what is causing my second app not to be served? I have:

- added
RewriteCond %{REQUEST_URI} ^/secondapp.*
RewriteRule .* - [L]
to my main app's .htaccess file
- checked the permissions on my dispatch.fcgi files are 755
- checked the logs and my apache error log reads
/home/paulgil/public_html/secondapp/dispatch.fcgi(20802) exit(communication error), terminated by calling exit(), return code: 1
There are no error in either of my rails production logs.

If I kill the fastcgi processes I can see the fastcgi process for my main app starting again in its fastcgi.crash.log when I hit it but my second app does not.

Any help is much appreciated.

Thanks

2008-02-07 07:18 AM

What exactly the Apache error log section in your cPanel control panel say ?

Can you please ensure that you have 755 permission set for all your app directories ?

If the permissions are are more than 755 Apache would throw su-exec errors.

2008-02-07 09:13 AM

Hi,

The error in the log reads:

[Thu Feb 07 11:42:25 2008] [notice] mod_fcgid: process /home/user/public_html/secondapp/dispatch.fcgi(22305) exit(communication error), terminated by calling exit(), return code: 1
[Thu Feb 07 11:42:19 2008] [notice] mod_fcgid: server /home/user/public_html/secondapp/dispatch.fcgi(22305) started

I notice the second error is not written immediately but 6 seconds after the first.

Both my apps have their directory permissions set to 755 and their files to 644 except the dispatch files which are 755 also.

2008-02-07 11:56 AM

Are both these apps on FastCGI?  If so, can you paste in the .htaccess for each?  What are their DocumentRoots (don't post your username, just use ~/something notation)

2008-02-07 03:51 PM

Hi,

Yes both these apps are on FastCGI. My main app has a document root of ~/public_html and my second app has a document root of ~/public_html/second_app.

The .htaccess file for my main app is:
# General Apache options
# AddHandler fastcgi-script .fcgi
AddHandler cgi-script .cgi
Options +FollowSymLinks +ExecCGI

# If you don't want Rails to look in certain directories,
# use the following rewrite rules so that Apache won't rewrite certain requests
#
# Example:
RewriteCond %{REQUEST_URI} ^/second_app.*
RewriteRule .* - [L]

# Redirect all requests not available on the filesystem to Rails
# By default the cgi dispatcher is used which is very slow
#
# For better performance replace the dispatcher with the fastcgi one
#
# Example:
#   RewriteRule ^(.*)$ dispatch.fcgi [QSA,L]
RewriteEngine On

# If your Rails application is accessed via an Alias directive,
# then you MUST also set the RewriteBase in this htaccess file.
#
# Example:
#   Alias /myrailsapp /path/to/myrailsapp/public
#   RewriteBase /myrailsapp

RewriteRule ^$ index.html [QSA]
RewriteRule ^([^.]+)$ $1.html [QSA]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ dispatch.fcgi [QSA,L]

# In case Rails experiences terminal errors
# Instead of displaying this message you can supply a file here which will be rendered instead
#
# Example:
#   ErrorDocument 500 /500.html

ErrorDocument 500 "<h2>Application error - Main App</h2>Rails application failed to start properly"
The .htaccess file for my second app is:
# General Apache options
# AddHandler fastcgi-script .fcgi
AddHandler cgi-script .cgi
Options +FollowSymLinks +ExecCGI

# If you don't want Rails to look in certain directories,
# use the following rewrite rules so that Apache won't rewrite certain requests
#
# Example:
#   RewriteCond %{REQUEST_URI} ^/notrails.*
#   RewriteRule .* - [L]

# Redirect all requests not available on the filesystem to Rails
# By default the cgi dispatcher is used which is very slow
#
# For better performance replace the dispatcher with the fastcgi one
#
# Example:
#   RewriteRule ^(.*)$ dispatch.fcgi [QSA,L]
RewriteEngine On

# If your Rails application is accessed via an Alias directive,
# then you MUST also set the RewriteBase in this htaccess file.
#
# Example:
#   Alias /myrailsapp /path/to/myrailsapp/public
#   RewriteBase /myrailsapp

RewriteRule ^$ index.html [QSA]
RewriteRule ^([^.]+)$ $1.html [QSA]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ dispatch.fcgi [QSA,L]

# In case Rails experiences terminal errors
# Instead of displaying this message you can supply a file here which will be rendered instead
#
# Example:
#   ErrorDocument 500 /500.html

ErrorDocument 500 "<h2>Application error - Second App</h2>Rails application failed to start properly"
Thank you for taking the time to help with this.

2008-02-08 12:40 PM

The following line was commented out in your subdomain's environment.rb file. I've uncommented it out.
---------
ENV['RAILS_ENV'] ||= 'production'

The site is now working fine.

2008-02-08 02:22 PM

I have the same problem as Gillarp, but my environment variable is already set for production.  Varun's first debugging question was to check permissions and report the Apache error log.  My app's directories are all set to 755 and the error log is empty.

Any help much appreciated!

2008-06-13 07:19 AM

I checked your sneak-peak domain and the site was loading fine. Can you confirm the current status.

2008-06-13 09:15 AM

Regards,
Rahul
Hi,

It's my subdomain (dev) that's the problem.

Thanks!
Lisa

2008-06-13 09:16 AM

Hello,

Ok..the issue occured because of 2 reasons. First the shebang line of dispatch.fcgi was wrong. It should be /usr/local/bin/ruby

Secondly the .htaccess file was missing. I uploaded a fresh .htaccess file and the issue got fixed.

2008-06-13 09:58 AM

Regards,
Rahul
Well that was dumb!  It was the result of a git freakout trying to make gitignore work...if anyone was wondering how I could miss anything so obvious.

Boy, do I appreciate the fab support here!


2008-06-18 07:28 AM


Hello Guest! In order to post you must be an active client with us, please log in or sign up.