I am moving a ROR web application to JRuby. So far it has been a very
pleasant and impressive experience. I am including all the gems I need
and creating an executable war file for distribution.
My question is, is there a way to use the executable war file yet still
have an external database.yml file, as well as, other files? The reason
I ask is the ROR web application is distributed to various platforms and
configurations where the database credentials may vary. How can I
support this ability where the war contains the database.yml and is used
when the war is started.
Thanks Rhett. You solution Looks interesting. From what I can tell is
this a Linux solution only? The web application I distribute runs on
many different OSs including Windows.
support this ability where the war contains the database.yml and is used
when the war is started.
You can push configuration to the deployment(i.e. configured once per
Servlet container) by reading resources from the CLASSPATH. You can plug
stuff into your database.yml with erb. In Tomcat, I drop deployment
specific configuration files in $CATALINA_HOME/lib
You use something like this in your database.yml to externalize the
entire thing.
You can do something like the following to replace individual
properties in database.yml with values read from a Java properties file.
(JavaProperties is my own helper class)
Thanks Rhett. You solution Looks interesting. From what I can tell is
this a Linux solution only? The web application I distribute runs on
many different OSs including Windows.
The default path in which it looks for the database credential files
(/etc/nubic/db) is unixy, but it can be changed (either through an
environment variable or by passing a parameter to Bcdatabase.load in
your database.yml). The library itself is pure ruby and should work
anywhere ruby works. If you find something that doesn’t work on windows,
please don’t hesitate to file an issue1.
Rhett
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.