Running my app in "production" under webrick

Changing environment files isn’t a good thing to do. If you want to run WEBrick under production mode, then run:

ruby script/server -e production

If you’re actually trying to run a Rails app in production over WEBrick, I can only recommend that you don’t. Go pick up Mongrel if you want a quick and easy production deployment environment. WEBrick is meant and built for development / testing only.

Jason

Does the apache setup not explicitly set -RAILS_ENV=production? Or maybe I’m just misreading what you’ve posted.

Anyway, I think it’s the ||= that’s messing with you. ||= means “set equal if nothing exists there yet”, so as ENV[‘RAILS_ENV’] is already set to ‘development’, that line is ignored. Change it to =, it will force production mode.

Jason

WEBrick starts up in development mode by default, you have to specify with ‘-e production’ to get into that mode.

Also, while Ruby ENV is the system environment, it’s only set for the execution of the ruby script and not changed for your shell session, so “echo $RAILS_ENV”, as you saw, doesn’t give you anything.

I guess I still don’t understand the problem. Is a production deploy acting like development or are you wanting to test your app in production mode to make sure there are no bugs there?

Jason

If you look at rails\railties\lib\commands\servers\webrick.rb, you can see where RAILS_ENV set to ‘development’ on startup. With this set, when Rails loads in environment.rb and sees the line: ENV[‘RAILS_ENV’] ||= ‘production’, Ruby says “well RAILS_ENV is already set to ‘development’, so ignore this line”.

As for the host, you should get a hold of someone there and find out why apache rails is not configured to run as production.

Hope that helps.

Jason