Motivation:
- I want to run multiple web services (applications, REST APIs, etc.) on shared infrastructure.
- However, if one of these goes down it should not take down the entire web container with them, thereby disabling other services.
- Solution: embed the container, which in my case is Jetty.
The setup we run:
Step 1: Have your main
start an instance of the embedded Jetty on a port number you desire. In our organisation, we use ports 8XXX
. See Startup.Java
(→link).
Step 2: Package it.
Step 3: Run/Deploy the JAR on your infrastructure box. We use Fabric.
Step 4: Use Apache vhost configuration to supply custom (non-port-number-based) URLs.
Here’s a link to the entire codebase on Github—web-app-microservice.
I like this approach as I think it is simple, clean, and relatively easy to understand and implement. However, if you spot any problems or have any suggestions, please leave a comment. (ツ)