Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Where to put the sqlite3-database when deploying a JRuby-On-Rails App as a war?

Background: I want to deploy a small JRuby-On-Rails-Application using warblers executable war, so I can just drop the .war-file and everyone can run it with java -jar app.war.

The application uses sqlite3 to store some data, and the production-db-file is located at WEB-INF/db inside the war.

Every time the app is started, winstone unpacks the war to a temp-directory, and all actions performed during this session are lost if the application is started the second time (because the production-db is unpacked again from the war-file).

So how can I use the same db-file every time the app ist started?

like image 381
Jan Avatar asked Dec 21 '10 10:12

Jan


1 Answers

You could either hard-code an absolute path in the database.yml, or add some logic to either pick a path outside of the webapp from an environment variable or a system property. For example:

production:
  db: <%= java.lang.System.getProperty('db') %>

Launch with:

java -Ddb=/path/to/db -jar app.war
like image 173
Nick Sieger Avatar answered Sep 30 '22 13:09

Nick Sieger