The Play Framework understands that applications may require changes in configuration prior to deployment in production. To simplify deploying, the command to deploy the application also accepts application-level configurations as arguments:
[PlayScala] $ start -Dapplication.secret=S3CR3T [info] Wrote /PlayScala/target/scala-2.10/playscala_2.10-1.0.pom (Starting server. Type Ctrl+D to exit logs, the server will remain in background) Play server process ID is 14904
Let's change the application's HTTP port as follows:
#setting http port to 1234 [PlayScala] $ start -Dhttp.port=1234
In some projects, the production and development configuration are maintained in two separate files. We could either pass one or more configurations or a different file altogether. There are three ways of specifying a configuration file explicitly. It can be achieved by using one of the following options:
config.resource
: This option is used when the file is within the class path (a file in application/conf
)config.file
: This option is used when the file is available on the local filesystem but not bundled with the application's resourcesconfig.url
: This option is used when the file is to be loaded from a URLSuppose our application uses conf/application-prod.conf
in production, we can specify the file as follows:
[PlayScala] $ start -Dconfig.resource=application-prod.conf
Similarly, we can also modify the logger configuration by replacing the config
key with logger
:
[PlayScala] $ start -Dlogger.resource=logger-prod.xml
We can also configure the underlying Netty server by passing the settings as arguments and this not possible through application.conf
. The following table lists some of the settings related to the server that can be configured in one or more ways.
The properties related to the address and port are as follows:
Property |
Purpose |
Default value |
---|---|---|
|
The address at which the application will be deployed |
|
|
The port at which the application will be available |
|
|
The |
The properties related to the HTTP requests (HttpRequestDecoder
) are as follows:
Property |
Purpose |
Default value |
---|---|---|
|
The maximum length of the initial line (for example, |
|
|
The maximum length of all the headers combined together |
|
|
The maximum length of the body or each chunk of it. If the length of the body exceeds this value, the content will be split into chunks of this size or less (in case of the last one). If the request sends the chunked data and the length of a chunk exceeds this value, it will be split into smaller chunks. |
|
The properties related to the TCP socket options are shown in the following table:
3.139.97.53