tomcatsbtsprayxsbt-web-plugin

How to launch multiple Tomcat instances with different ports per Spray application using xsbt-web-plugin?


I have a Spray app that will be ultimately deployed to an array of Apache Tomcat servers.

During development it would be convenient to be able to launch multiple instances of Tomcat running the app on different ports from sbt.

The checkbox item "Running multiple container instances in a single SBT project" in this issue suggests that it is supported but I can't seem to find a step-by-step procedure to get it set up in my project.

Can anyone confirm if this is possible at all, and if so how to configure it?


Solution

  • This is now supported in xsbt-web-plugin version 3.0.0.

    You can configure your webapp to launch in multiple containers by setting containerScale in your sbt configuration:

    build.sbt:

    containerScale := 5
    

    This configures <container>:start, <container>:quickstart, and <container>:debug to fire up five instances of the container, and <container>:stop to tear them all down.