Right now I'm setting up a system where two instances of the same application will be co-existing on the one server.
It's going in the unicorn init script, the delayedjob init script, and a shell script I've created that su's to the application's user, chdir's the app's directory, and sets RAILS_ENV to production. I've just done the same thing for redis & sphinx and it's going relatively well. On Sun, Jul 29, 2012 at 1:48 PM, Mike Bailey <[email protected]> wrote: > Thanks for posting example Michael. > > When and how are you setting the environment variable? > > - Mike > > Sent from my iPhone > > On 29/07/2012, at 11:55 AM, Michael Pearson <[email protected]> wrote: > > Not what I meant - that's controlling individual the database connection > of individual models. It could be used, I guess, to override the connection > mechanism to use something other than database.yml, but that too seems > inelegant (eg, it won't work with the Delayed Job implied model) > > As an example, here's what I've got as an interim YAML / ERB based > solution: > > https://gist.github.com/3195668 > > On Sun, Jul 29, 2012 at 11:43 AM, Mark Ratjens <[email protected]> wrote: > >> In the first Rails Recipes book by Chad Fowler, there's a recipe called >> Connecting to Multiple Databases. I seem to remember using something like >> it circa 2006, but can;t lay my hands on the code (it was in a private repo >> of a company that was eventually bought out). >> >> Just a little snippet from the recipe to give some clues: >> >> class External < ActiveRecord::Base >> >> self.abstract_class = true establish_connection :products >> >> end >> >> class Product < External >> >> end >> >> class TaxConversion < External >> >> end >> >> >> On 29 July 2012 11:28, Michael Pearson <[email protected]> wrote: >> >>> Hi, >>> >>> Lincoln Stoll recently gave a presentation about the 12 Factor App at >>> DevOps Melbourne. One of the take-homes from that presentation for me was >>> the idea of using URIs in environment variables to configure >>> environment-specific (vs app specific) parts of the application: >>> http://www.12factor.net/config >>> >>> For instance, it'd be nice if I could have on my system: >>> >>> DATABASE_URI=mysql://foo:bar@localhost/myDatabase >>> >>> And then keep application specific database config (eg, my locale) to >>> the database.yml. >>> >>> I'm wondering if anybody has implemented this already in a gem, or a >>> gist, or similar. It's relatively trivial to use ERB to do this in your >>> database.yml right now, but seems inelegant. >>> >>> Also, I hate ERB. Just putting that out there. >>> >>> -- >>> Michael Pearson >>> >>> >>> -- >>> You received this message because you are subscribed to the Google >>> Groups "Ruby or Rails Oceania" group. >>> To post to this group, send email to [email protected]. >>> To unsubscribe from this group, send email to >>> [email protected]. >>> For more options, visit this group at >>> http://groups.google.com/group/rails-oceania?hl=en. >>> >> >> >> >> -- >> >> >> *Mark Ratjens* >> *Co-founder, Habanero Software* >> * >> * >> Sydney, Australia >> [email protected] >> @MarkRatjens <[email protected]> >> www.habanerohq.com <http://habanerohq.com> >> +61 414 159 357 >> >> -- >> You received this message because you are subscribed to the Google Groups >> "Ruby or Rails Oceania" group. >> To post to this group, send email to [email protected]. >> To unsubscribe from this group, send email to >> [email protected]. >> For more options, visit this group at >> http://groups.google.com/group/rails-oceania?hl=en. >> > > > > -- > Michael Pearson > > > -- > You received this message because you are subscribed to the Google Groups > "Ruby or Rails Oceania" group. > To post to this group, send email to [email protected]. > To unsubscribe from this group, send email to > [email protected]. > For more options, visit this group at > http://groups.google.com/group/rails-oceania?hl=en. > > -- > You received this message because you are subscribed to the Google Groups > "Ruby or Rails Oceania" group. > To post to this group, send email to [email protected]. > To unsubscribe from this group, send email to > [email protected]. > For more options, visit this group at > http://groups.google.com/group/rails-oceania?hl=en. > -- Michael Pearson -- You received this message because you are subscribed to the Google Groups "Ruby or Rails Oceania" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/rails-oceania?hl=en.
