[Mongrel] setting enviroment variable

ufuk kocolu ufuk at pilli.com
Wed Feb 7 04:44:23 EST 2007


Luis Lavena wrote:
> On 2/6/07, ufuk kocolu <ufuk at pilli.com> wrote:
>   
>> Luis Lavena wrote:
>>     
>>> On 2/6/07, ufuk kocolu <ufuk at pilli.com> wrote:
>>> <snip>
>>>
>>>       
>>>> I have one rails application which runs severals sites according to that
>>>> enviroment variable.
>>>>
>>>> http://article.gmane.org/gmane.comp.lang.ruby.rails/14513
>>>>
>>>> The problem is, I can do what you suggest but I want to use mongrel as
>>>> an NT service  (I can create multiple NT services for multiple sites)
>>>> for that, I have to set this enviroment variable elsewhere.
>>>>
>>>>
>>>>         
>>> OK, you forgot to include in your post THAT IMPORTANT part.
>>>
>>> NT services cannot set environment variables *per-service*, unless you
>>> ran your application for every instance in one specific user account
>>>
>>> (ex. site1 using user1, site2 => user2, etc).
>>>
>>> That will require set environment for each user account, also making
>>> your application code vulnerable to _all_ these accounts (NT security
>>> and permissions).
>>>
>>>
>>>       
>>>> If there is an option to run system commands before mongrel service
>>>> initializes, that would work for me.
>>>>
>>>>
>>>>         
>>> There isn't. Mongrel execute the config script after loading rails environment.
>>>
>>> Could I question your decision base your application/system design in
>>> a mail that dates 1 year, 29 weeks, 5 days, 12 hours and 26 minutes
>>> old?
>>>
>>> I got better functionality and less code duplication implementing
>>> "instances" versions of my application:
>>>
>>> All your instances share the same codebase of your application, which
>>> is bundled inside a gem.
>>>
>>> Each instance could be run like a normal rails application, having its
>>> own database.yml, but without duplicated models and controllers
>>> between instances.
>>>
>>> That is Fossilize, the base on what Radiant based their gemification
>>> distribution.
>>>
>>> Maybe that approach will suite better your needs.
>>>
>>>
>>>       
>> Thank you for your answer. The fact is, my application is  a year old.
>> So that solution was appropriatte back then. I'll check your suggestion
>> but I won't be able to change a whole application to that method.
>>
>>     
>
> Fossilize is 1 year old ;-)
>
> Original article in spanish:
>
> http://rubyargentina.soveran.com/gemrailsapp
>
> And the ANN in ruby-forum:
>
> http://www.ruby-forum.com/topic/67435#84031
>
>
>   
>> Then, I'm stuck here.  I doubt i will find a way out of this.
>>
>>     
>
> The only workaround I see for you is hack in the top of your
> environment file something that based on the port set to start the
> application, set the constant SITE (used in erb inside database.yml).
>
> Since you cannot start 2 instances in the same port, I guess this could work.
>
> (You will require look into ARGV and get -p or --port option from it.)
>
> The other, easier and less safer way will be use the multiple user
> accounts option.
>
>   
I can hack enviroment.rb but I don't think I can retrieve startup 
parameters using ARGV.

I checked and logged contents of ARGV and it's empty.

Can I retrieve it some other way (maybe using Rails::Configuration 
something like that) ?










More information about the Mongrel-users mailing list