Search code examples
sbtspraysbt-assembly

Spray Application Run Against a Configuration


I have a Spray application that I would like to run against a different configuration file. In my resources folder, I have a set of configuration files as:

resources
  application.conf
  application.integration.conf
  application.uat.conf

With the Play framework, I normally put these files inside the conf folder and I do the following to run the application:

sbt -Dconfig.file=conf/application.uat.conf run

How can I do this with Spray application structure?

Additionally, how could I jar a spray application using sbt so that I can deploy it to a specific environment and just have a script that takes care of starting and stopping the Spray HTTP server?


Solution

  • I don't know exactly how you are packing and deploying your app, but you can try this: by default, application.conf will be picked up. Additionally, you can override it when running your app with the config.resource property in a similar fashion as config.file. Moreover, you can have specific configurations for different environments as you have, and they can include application.conf.

    All these details are crystal clear in the Akka documentation: http://doc.akka.io/docs/akka/2.4.1/general/configuration.html#Including_files

    As for packaging it, you have several alternatives; two good candidates are sbt assembly and sbt-native-packager plugins.