Where to place the sqlite3 database when deploying the JRuby-On-Rails application as a war?

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

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

Each time the application starts, winstone unpacks the war in a temporary directory, and all the actions performed during this session are lost if the application is launched a second time (because production-db is unpacked again from the war file).

So, how can I use the same db file every time the application starts?

+4
source share
1 answer

You can either hardcode the absolute path into database.yml, or add some logic to select a path outside the webapp from an environment variable or system property. For instance:

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

Launch with:

 java -Ddb=/path/to/db -jar app.war 
+4
source

Source: https://habr.com/ru/post/1332876/


All Articles