crysfel
By:
crysfel

Unicorn not reading environment variables correctly

January 31, 2014 8.6k views
Hi Guys. I have deployed a rails app on ubuntu using the on-click-install droplet, everything is working correctly except for some environment variables that are not been read by my app. I have defined these variables on /etc/environment as follow: export S3_BUCKET=mybucket export S3_KEY=HJKD.... export S3_SECRET=+iSJKL..... After defined those variable I did the source /etc/environment, I also have restarted the droplet but in my app those variables are NIL. ENV['S3_BUCKET'] === nil Any help would be appreciate. Regards
4 comments
4 Answers
Edit /etc/default/unicorn and insert the export lines into it. Does that work?
Yes! it works!! thank you so much for your help!!

Regards

/etc/default/unicorn should contain the following:

# ENV Variables for S3
export S3_KEY='YOUR_S3_KEY_HERE'
export S3_SECRET='YOUR_S3_SECRET_HERE'
export S3_BUCKET='YOUR_BUCKET_HERE'
export S3_REGION='YOUR_BUCKET_REGION'

By default your S3 region should be us-east-1, if it is then don't define a region. Otherwise define the region, in my my case its 'us-west-1'.

Have another answer? Share your knowledge.