binaerbaum
binaerbaum

Reputation: 51

Play 2 - External configuration file fails to load in production mode

I am having trouble including an external file in the application.conf of my play 2.1.1 application in production mode (when launched with start)

Following the official documentation I added an include statement in my application.conf :

[...]
include "/absolute/path/to/external/config/file.conf"

The content is loaded this way :

configuration.getConfig("some-key")

It works fine in dev mode, but fails in production mode (it's always None).

This is preventing me from deploying my application to production.

Any help/ideas would be greatly appreciated.

EDIT: Following Saffron's comment I tried a few workarounds.

Removing the first slash from the include statement did not work.

Loading the configuration file via -Dconfig.file=/abs/path gave weird results and it seems that Play is not behaving in a consistent way:

play start -Dconfig.file=/path/to/file.conf does not work. However launching play THEN running start -Dconfig.file=/path/to/file.conf does work ??!!

So I ended up creating a new configuration instead of using Play's:

val conf = ConfigFactory.parseFile(new File("/path/to/file.conf")).resolve()
val myValues =  new Configuration(conf).getConfig("some-key").get

Hope it can help someone who ran into the same issue.

Upvotes: 4

Views: 1607

Answers (1)

Saffron
Saffron

Reputation: 682

I had a problem in which my images weren't displayed correctly in prod mode, but were ok in dev mode. The solution was to write the path as ("images/...") instead of ("/images/..."). Try it, just for science sake.

Anyway,if this doesn't work, here is some documentation about additional Conf in prod mode, with console lines to override the file. $ start -Dconfig.file=/opt/conf/prod.conf

http://www.playframework.com/documentation/2.0/ProductionConfiguration

Upvotes: 2

Related Questions