-
Notifications
You must be signed in to change notification settings - Fork 0
ProductionConfiguration
When running an application in production mode you can override any configuration. This section covers the more common use cases.
All these additional configurations are specified using Java System properties and can be used directly if you are using one of the start
script generated by Play.
You can provide both HTTP port and address. The default is to listen on port 9000
at the 0.0.0.0
address (all addresses).
$ start -Dhttp.port=1234 -Dhttp.address=127.0.0.1
Note that these configuration are only provided for the default embeded Netty server.
You can specify any JVM arguments to the start
script. Otherwise the default JVM settings will be used:
$ start -Xms128M -Xmx512m -server
The default is to load the application.conf
file from the classpath. You can specify an alternative configuration file if needed:
It will search for an alternative configuration file in the application classpath (you usually provide these alternative configuration files into your application conf/
directory before packaging). Play will look into conf/
so you don't have to add conf/
.
$ start -Dconfig.resource=prod.conf
You can also specify another local configuration file not packaged into the application artifacts:
$ start -Dconfig.file=/opt/conf/prod.conf
You can also specify a configuration file to be loaded from any URL:
$ start -Dconfig.url=http://conf.mycompany.com/conf/prod.conf
Note that you can always reference the original configuration file in a new
prod.conf
file using theinclude
directive, such as:include "application.conf" key.to.override=blah
Sometimes you don't want to specify another complete configuration file, but just override a bunch of specific keys. You can do that by specifying then as Java System properties:
$ start -Dapplication.secret=verysecretkey -Ddb.default.password=toto
You can also reference environment variables from your application.conf
file:
my.key = defaultvalue
my.key = ${?MY_KEY_ENV}
Here, the override field my.key = ${?MY_KEY_ENV}
simply vanishes if there's no value for MY_KEY_ENV
, but if you set an environment variable MY_KEY_ENV
for example, it would be used.
Create an alternative logback config file called application-logger.xml
and copy that to <app>/conf
You can also specify another logback configuration file via a System property.
Specify another loback configuration file to be loaded from the classpath:
$ start -Dlogger.resource=conf/prod-logger.xml
Specify another logback configuration file to be loaded from the file system:
$ start -Dlogger.file=/opt/prod/prod-logger.xml
Specify another loback configuration file to be loaded from an URL:
$ start -Dlogger.url=http://conf.mycompany.com/logger.xml
It is possible to change the file path to the created RUNNING_PID file which contains the process id of the started application. Normally this file is placed in the root directory of your play project.
$ start -Dpidfile.path=instance1
This changes the directory relative to the root folder. You could also use absolute paths. With this option it is possible to start multiple play instances without colliding RUNNING_PID files (actually play won't start another instance). Don't forget to create the directory.
- Deploying your application
- Creating a standalone version
- Additional configuration
- Set-up a front-end HTTP server
- Deploying to Heroku
- Deploying to Cloudbees
- Deploying to Cloud Foundry
- Installing Play
- Creating a new application
- Anatomy of a Play application
- Using the Play console
- Setting-up your preferred IDE
- Sample applications