I'd like to know how to start a packaged play v2.3.7 application (created by the dist
command) in Prod
and Dev
modes.
We create our distributable artifact using sbt dist
, which produces a zip file according to these instructions. We copy the zip file to the machine it will run on, unpack it, and start it according to the instructions on that page. However, it always starts so that Play.isProd
evaluates to true
.
When developing our application, we can start it using activator start
, which causes Play.isProd
to return true
, or activator run
/ activator test
, which cause Play.isProd
to return false
.
We'd like to know if there is any way to start the packaged application and be able to control the state of Play.isProd
, so that we can have a test instance running on our test server, and a prod instance on our prod server.
Our current workaround is to have a custom setting in application.conf
and examine that using Play.current.configuration.getBoolean("play_mode").getOrElse(true)
. I feel we should be using the built-in functionality instead.
Not sure if I fully understand your questions, but here goes.
My spontaneous recommendation would be to use environment variables, as this always decouples configuration from code, and binds specific configuration to machine/environment.
But to answer your question :)
It is possible to have an additional .conf files and set the one to be used on start/run:
activator start "-Dconfig.resource=dev.conf"
Alternative if this is for a temporarily fix you could override specific configuration keys directly from command line:
activator start "-Dapplication.some.conf=override -Ddb.default.password=some_pass"
// This might even work, not sure
activator start "-Dapplication.mode=DEV"
Read more:
https://www.playframework.com/documentation/2.3.x/ProductionConfiguration
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With