Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unicorn.rb configuration depending on environment

I've got a line in config/unicorn.rb that looks like so:

working_directory "/SomePath/Web\ Development/Rails/learning"

but in the production environment, it needs to be a different path. I want do keep as much as I can under source control (haven't had to give up anything yet). Is there a way to set the working_directory based upon the environment?

like image 683
Matthew Avatar asked Mar 28 '12 14:03

Matthew


2 Answers

How are you trying to access RAILS_ENV or RACK_ENV? It should be through "ENV" like...

ENV['RAILS_ENV'] 

... or ...

ENV['RACK_ENV']

One or the other should be available when you pass unicorn the "-E" flag (I can't remember which for sure, but I think it's RACK_ENV).

like image 90
jmervine Avatar answered Sep 27 '22 16:09

jmervine


Using unicorn_rails makes the environment variables available.

like image 32
Antonio Kamiya Avatar answered Sep 27 '22 16:09

Antonio Kamiya