dispatch.fcgi not putting server into Production mode

I'm trying to get production set without changing the environment.rb file.

I'm using Apache/fastcgi with the following in /etc/httpd/conf.d/fastcgi.conf:

<IfModule mod_fastcgi.c>     FastCgiConfig -idle-timeout 900     FastCgiIpcDir /tmp/fastcgi_ipc/     AddHandler fastcgi-script .fcgi .rb FastCgiServer /var/www/vhosts/kettlewell.net/subdomains/jr/httpdocs/dispatch.fcgi -idle-timeout 120 -initial-env RAILS_ENV=production -processes 1 FastCgiServer /var/www/vhosts/kettlewell.net/subdomains/bridal/httpdocs/dispatch.fcgi -idle-timeout 120 -initial-env RAILS_ENV=production -processes 1 </IfModule>

I thought that '-initial-env RAILS_ENV=production' was supposed to get production working, but it's still creating/generating development.log and trying to use my development user/pass for MySQL.

I also tried adding:

SetEnv RAILS_ENV production in my httpd.conf file, with no luck

I can set it up in config/environment.rb , but that is purpose defeating.

What am I missing?

rails: 1.1.6 , ruby 1.8.4, mod_fastcgi: 2.4.2

Matt

Hey Matt, I believe the apache setting is:

  -initial-env production

Since you're setting it incorrectly, it's likely being set to the
default of Development - which is then overiding your environment.rb
setting.

Cheers, Jodi General Partner The nNovation Group inc. www.nnovation.ca/blog

I tried your suggestion to no avail.

The agile book and several online refs/tutorials put it as -initial-env RAIL_ENV=production , but regardless, neither seems to be working.

I did notice that a ps -ef on my server only shows that dispatch.fcgi is called, but doesn't show any arguments. Am I missing an escapement or quoting somewhere?

If it matters, this is Apache 2.0.54 with FC4, ruby 1.8.4 and rails 1.1.6 with mod_fastcgi 2.4.2

Matt

Howdy there.

Let me be the first to suggest you abandon fastcgi and proceed directly to mongrel. I installed an application on a similar setup recently, and used apache 2.0.x -> balance -> mongrels via mongrel_cluster and it was a snap.

If you have the luxury of upgrading Apache to 2.2.3 or higher, you can bypass balance as well.

>> >> Hey Matt, I believe the apache setting is: >> >> -initial-env production >> >> Since you're setting it incorrectly, it's likely being set to the >> default of Development - which is then overiding your environment.rb >> setting. > > I tried your suggestion to no avail. > > The agile book and several online refs/tutorials put it as > -initial-env RAIL_ENV=production , but regardless, neither seems to be > working. > > I did notice that a ps -ef on my server only shows that
> dispatch.fcgi is > called, but doesn't show any arguments. Am I missing an escapement or > quoting somewhere? > > If it matters, this is Apache 2.0.54 with FC4, ruby 1.8.4 and rails > 1.1.6 with mod_fastcgi 2.4.2

Howdy there.

Let me be the first to suggest you abandon fastcgi and proceed directly to mongrel. I installed an application on a similar setup recently, and used apache 2.0.x -> balance -> mongrels via mongrel_cluster and it was a snap.

If you have the luxury of upgrading Apache to 2.2.3 or higher, you can bypass balance as well.

Howdy there.

Let me be the first to suggest you abandon fastcgi and proceed directly to mongrel. I installed an application on a similar setup recently, and used apache 2.0.x -> balance -> mongrels via mongrel_cluster and it was a snap.

If you have the luxury of upgrading Apache to 2.2.3 or higher, you can bypass balance as well.

It all sounds great, and Mongrel does seem to be the trend, so I think I do need to look into it in more depth. My hesitation is that I have some Lua apps that are using fastcgi as well. I really haven't been happy with the fastcgi/Lua connection anyhow, so I may look at Mongrel for Ruby and find a Lua alternative. I suppose I could, in theory, run both fastcgi and Mongrel, but I think that's playing with fire.

Hey Matt, I believe the apache setting is:

  -initial-env production

Since you're setting it incorrectly, it's likely being set to the default of Development - which is then overiding your environment.rb setting.

Cheers, Jodi General Partner The nNovation Group inc. www.nnovation.ca/blog

I tried your suggestion to no avail.

The agile book and several online refs/tutorials put it as -initial-env RAIL_ENV=production , but regardless, neither seems to be working.

I did notice that a ps -ef on my server only shows that dispatch.fcgi is called, but doesn't show any arguments. Am I missing an escapement or quoting somewhere?

If it matters, this is Apache 2.0.54 with FC4, ruby 1.8.4 and rails 1.1.6 with mod_fastcgi 2.4.2

Matt

I stand corrected Matt. sigh.

For what it's worth, here's my syntax. Note I've not enclosed within an if module

LoadModule fastcgi_module modules/mod_fastcgi.so FastCgiIpcDir /tmp/fcgi_ipc/ FastCgiServer /var/www/html/tln/public/dispatch.fcgi -idle-timeout 6000 \          -initial-env RAILS_ENV=development -processes 1 AddHandler fastcgi-script .fcgi

+ it seems you've got two fastcgi startups on one line? Is that permissible? > FastCgiServer /var/www/vhosts/kettlewell.net/subdomains/jr/httpdocs/dispatch.fcgi -idle-timeout 120 -initial-env RAILS_ENV=production -processes 1 FastCgiServer /var/www/vhosts/kettlewell.net/subdomains/bridal/httpdocs/dispatch.fcgi -idle-timeout 120 -initial-env RAILS_ENV=production -processes 1

You likely have, but I'd also double verify your paths and the write perms on FastCgiIpcDir.

As another thought, be sure you kill the old ones - the apaches restart doesn't always cleanup up well.

good luck. Jodi

Thanks for your reply. See comments inline:

LoadModule fastcgi_module modules/mod_fastcgi.so FastCgiIpcDir /tmp/fcgi_ipc/ FastCgiServer /var/www/html/tln/public/dispatch.fcgi -idle-timeout
6000 \          -initial-env RAILS_ENV=development -processes 1 AddHandler fastcgi-script .fcgi

I see that you have RAILS_ENV set to development. What happens if you set it to production? Does it work?

+ it seems you've got two fastcgi startups on one line? Is that
permissible?

This is an email formatting issue. They are actually on 2 separate lines.

> FastCgiServer /var/www/vhosts/kettlewell.net/subdomains/jr/ httpdocs/dispatch.fcgi -idle-timeout 120 -initial-env
RAILS_ENV=production -processes 1 FastCgiServer /var/www/vhosts/ kettlewell.net/subdomains/bridal/httpdocs/dispatch.fcgi -idle- timeout 120 -initial-env RAILS_ENV=production -processes 1

You likely have, but I'd also double verify your paths and the write
perms on FastCgiIpcDir.

Yeah I double checked the permissions and path of /temp/fastcgi_ipc/ user and group apache and are 755

and the 2 dispatch.fcgi's exist are owned by the domain owner and are executable (755)

As another thought, be sure you kill the old ones - the apaches
restart doesn't always cleanup up well.

I just tried that. killed all the dispatch.fcgis, changed my environment.rb file back so that RAILS_ENV isn't explicitly set, restarted httpd, and checked site. No good, its in development mode again.

good luck. Jodi

Any other thoughts? I'm beginning to think I'm stuck with setting the RAILS_ENV explicitly. Matt

hmm. Matt, that was a bad example! Yes I have many running on the same box in production such as,

FastCgiServer /var/www/html/mephisto/public/dispatch.fcgi -idle-timeout 6000 \          -initial-env RAILS_ENV=production -processes 4

Is is possible that you have the environment variable RAILS_ENV set at the os level? Or is dispatch.fcgi doing something non-standard? Those are my last thoughts I think Matt - I've run to the end of the possibilities I can imagine.

But, to echo Tom's thought, I will quick likely be deploying with Mongrel down the road - so far in development it's a dream.

Cheers, Jodi General Partner The nNovation Group inc. www.nnovation.ca/blog

on-innovation.gif

Is is possible that you have the environment variable RAILS_ENV set
at the os level? Or is dispatch.fcgi doing something non-standard?
Those are my last thoughts I think Matt - I've run to the end of the
possibilities I can imagine.

But, to echo Tom's thought, I will quick likely be deploying with
Mongrel down the road - so far in development it's a dream.

Cheers, Jodi General Partner The nNovation Group inc. www.nnovation.ca/blog

I'm beginning to think that either the apache binary has something funky compiled in or I have some non-standard configuration hidden somewhere. I am on a Plesk VPS, and they do some things off to the side, but who knows... for now I'll just edit my environment.rb file. Mongrel, unfortunately, won't help me because of my Lua projects. Maybe I'll have to use different servers... but I digress.

Jodi, Thanks so much for your help Matt