I’d like to have Jetty running on a production server and when I have a new code package to deploy I’d like to be able to do an “sbt package” to package up my code into a war file, then copy it over to the production machine’s webapp folder.
Is that reasonable? If so, what is the best way to start Jetty as a daemon? Will it see the new file and automatically reload my app or do I need to restart it somehow?
The main problem with what you are suggesting is that the configuration required to have the server listen or monitor the webapps folder is that there will be a production hit.
While this type of configuration is great for development, it isn’t recommended for production applications.
With that said, what you’re looking for is a ContextDeployer, which can be configured in jetty.xml. See the Jetty documentation for your specific version of Jetty for the exact details:
The “scanInterval” is what tells the server to monitor the contexts folder. Every 5 seconds, it checks to see if the files changed.
Finally, to start Jetty as a daemon, just use the scripts they provide you in the /bin folder:
To stop Jetty, run:
And to restart Jetty, run:
Again, see The Jetty Documentation or The Webtide Website for the exact documentation for whatever version of Jetty you’re running. Different versions can differ drastically in terms of how the server is configured.