3 Launching
This chapter introduces how to launch a Ratpack application, and the associated launch time configuration.
3.1 Launch configuration
To launch a Ratpack application, you must create a LaunchConfig. This can then be used with the RatpackServerBuilder method to create a RatpackServer that can then be started.
Note that one of the LaunchConfig object’s responsibilities is to provide a HandlerFactory implementation. This factory is responsible for creating the handler that is effectively the Ratpack application. See the chapter on handlers for more details.
One option for building a LaunchConfig is to use the LaunchConfigBuilder. Another option is to use LaunchConfigs which is able to build a launch config from system properties and a properties file.
3.2 RatpackMain
The RatpackMain class is a convenient entry point (i.e. main class) that bootstraps a Ratpack application. When building with Gradle, this is the default main class.
The minimum requirement for launching a RatpackMain based application, is to ensure there is a ratpack.properties file on the JVM classpath that indicates the application HandlerFactory…
handlerFactory=org.my.HandlerFactory
All aspects of the LaunchConfig can be specified in this properties file. Aspects can also be environmentally overridden by JVM system properties. See RatpackMain for details.