In production environment, application and logging configuration will be read from files stored in a dedicated directory on the server, creating a more secure environment. You may also choose to generate application keys directly on the server, thus avoiding transmission of the keys over networks during the upload process. Storing application and logging configuration in a directory separate from the application will also prevent an accidental override of the files during an update.
If you haven't yet written an application, please download a sample web app from LineDrop's repository:
Open build.sbt on the root of your application project and update name and version. For example:
On your machine, browse to your home directory and then add a new directory.
Name the new directory deployment. All files to be uploaded to the server will be stored in the deployment directory.
Copy application.conf from the conf directory of your project and paste it into the deployment directory.
Rename the file to production.conf.
Open production.conf in a text editor and update the following settings:
Example of an application configuration:
Copy logback.xml from the conf directory of your project and paste it into the deployment directory.
Open the file in a text editor and change the log file location in the FILE appender section to /var/www/application_log/application.log. Application is the name of your application.
For example, /var/www/code_log/application.log.
Change all logger levels to INFO or above.
Example of a log configuration:
Open Terminal and browse to the project root. Build a distribution version of your application.
Wait for the process to complete. The final ZIP archive will be placed in the target/universal/ directory of your project. The file will be named application-version.zip, where application is the name of your project and version is the release version number, both defined in build.sbt. For example: code-0.2.zip
Copy the application-version.zip file to the deployment directory.
Download the collection of application maintenance scripts:
The collection contains several scripts to make application deployment and maintenance a straight-forward process.
Modify APP_DIR and APP_DIR_CONF variables in each script to reflect the name of your application. The name should be the same as in build.sbt. For example:
Copy the scripts to the deployment directory.
Please verify that the deployment directory contains all files.
In Terminal, browse to deployment directory.
Connect to the server with the SFTP connection script.
Upload all deployment files to the server. The files will be saved on the server in the user’s home directory.
Exit SFTP connection.
Connect to the server with the SSH connection script.
Set permissions to read, write, and execute for all scripts.
chmod 700 go setup start stop update
Run the setup script to create production directories and move configuration files.
The script executes several tasks:
Close your SSH session.
By now the application has been deployed and is running on the server. However, it is not yet connected to the reverse proxy server.