4

I have my configuration for my Scala Play application in my application.conf file.

For now, everytime I want to change the configuration I have to make a deployment.

Can anybody help me finding out, how to expose the Configuration as a MBean? I would like to change the configuration without deployment.

Didn't find any documentation on this.

gun
  • 1,046
  • 11
  • 22
  • 1
    could be usefull http://stackoverflow.com/questions/16088411/how-to-change-play-2-framework-db-configuration-at-runtime – vvg Feb 29 '16 at 09:38
  • This look not very handy. With JMX, I could see the current configuration and change the current configuration more easy. – gun Feb 29 '16 at 10:21
  • It never too easy, configuration already loaded into application. For ex. DB connection already setup. Even if you change Configuration object it does not necessary means your services use latest configs. – vvg Feb 29 '16 at 11:57
  • @rumoku that's right, but still would be good to be able to restart instead of redeploy :) Will track this question, probably community will have a solution. – Alexander Arendar Feb 29 '16 at 12:03
  • 1
    @Alexander Arendar for yourscenario check the link I've added above. It's recommended to override `onLoadConfig` method of `GlobalSetting` trait, where you can use different data source for your configuration. – vvg Feb 29 '16 at 12:57

1 Answers1

1

Redeploy just for a configuration change is really boring and I understand you want to avoid that.

Changing configuration while the application is running is a risky operation and I would not recommend going in that direction. But there are a few techniques that the framework provides that would only require a restart of the application.

Play allows you to point to an external file with your configuration

$ your-app -Dconfig.file=/full/path/to/conf/application-prod.conf

Besides that in your conf file you can use environment variables, so you can configure different servers differently using the same application.conf

my.key = defaultvalue
my.key = ${?MY_KEY_ENV}

And run your app using

$ your-app -DMY_KEY_ENV=bar

Reference:

Jonas Anso
  • 2,057
  • 14
  • 13