# Passing environment variables to mongrel

**URL:** <https://www.ruby-forum.com/t/passing-environment-variables-to-mongrel/139356>\
**Category:** Mongrel\
**Created:** [June 3, 2008, 7:51am UTC](https://www.ruby-forum.com/t/passing-environment-variables-to-mongrel/139356 "2008-06-03T07:51:33Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![jenny\_w](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/e47774/32.png) [@jenny\_w](https://www.ruby-forum.com/u/jenny_w)\
**Post date:** [June 3, 2008, 7:51am UTC](https://www.ruby-forum.com/t/passing-environment-variables-to-mongrel/139356/1 "2008-06-03T07:51:33Z")

</div>

## The Rails app I’m working on requires an environment variable to be set. I thought I could do this in my cap deploy script. Unfortunately, it seems that the Mongrel processes that are started up by Mongrel Cluster have their own environments and any environment variables set in the deploy script aren’t passed on. I was able to verify this by having my deploy script run a rake task that outputs the value of of the environment variable I need

the value is what I’d expect. I then set the Rails app to add that same  
environment variable in a log message, and it shows that the value is  
nil.  
Does anyone have any suggestions for setting an environment variable?

Thanks!

---

<div class="post-metadata">

**Author:** ![jenny\_w](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/e47774/32.png) [@jenny\_w](https://www.ruby-forum.com/u/jenny_w)\
**Post date:** [June 3, 2008, 8:13am UTC](https://www.ruby-forum.com/t/passing-environment-variables-to-mongrel/139356/2 "2008-06-03T08:13:51Z")

</div>

Never mind; turns out this is a capistrano issue (running mongrel via  
sudo).  
Thanks!

---

<div class="post-metadata">

**Author:** ![jenny\_w](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/e47774/32.png) [@jenny\_w](https://www.ruby-forum.com/u/jenny_w)\
**Post date:** [June 3, 2008, 4:10pm UTC](https://www.ruby-forum.com/t/passing-environment-variables-to-mongrel/139356/3 "2008-06-03T16:10:50Z")

</div>

Jenny,

Environment variables can be defined in the /etc/init.d/  
mongrel\_cluster script.

Bill S.
