Skip to content

Running a Server

Paul Ambrose edited this page Aug 2, 2020 · 12 revisions

Running a Server

Run the main() in src/main/kotlin/ContentServer.kt to view your ReadingBat content.

Running with redis enabled is optional. It is unnecessary for creating content, but highly advisable in production.

The server can be run in two modes: development and production.

Development Mode

Development mode allows you to see updates to the Content.kt description file and challenge code without restarting the server.

Enable development mode with:

  1. Assign readingbat.site.production in application.conf to false.

  2. Uncomment ktor.deployment.watch in application.conf.

Run the server in development mode with:

  1. Run the server with: make run in a terminal window. Alternatively, you can run the main() in ContentServer.kt from your IDE.

  2. Compile the code continuously with: make cc in a different terminal window. This step is optional. Without it, you will have to restart the server after changes to the Content.kt description file.

  3. View your content at http://0.0.0.0:8080 (or http://127.0.0.1:8080 if you are using Windows)

Production Mode

Production mode will cache challenges and parse them only once.

Enable production mode with:

  1. Adjust the readingBatContent.repo property in Content.kt to reference the appropriate GitHubRepo value.

  2. Assign readingbat.site.production in application.conf to true.

  3. Comment out ktor.deployment.watch in application.conf.

Create an uberjar with: make uberjar

Run the server in production with: java -jar build/libs/server.jar

Deployment Options

There are numerous deployment hosting options including: docker, Heroku, gitpod.io