Skip to content

Instantly share code, notes, and snippets.

@arthurtsang
Created February 9, 2015 00:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save arthurtsang/d1c77f7a84443d893646 to your computer and use it in GitHub Desktop.
Save arthurtsang/d1c77f7a84443d893646 to your computer and use it in GitHub Desktop.
Ratpack 0.9.13 main
public class MyAppMain {
private final static Logger logger = LoggerFactory.getLogger(MyAppMain.class);
private final static String ENV_PREFIX_PROPERTY = "MYAPP_ENV_PREFIX";
private final static String ENV_PREFIX_DEFAULT = "MYAPP_";
public static void main(String[] args) {
String propertyPrefix = System.getenv().getOrDefault(ENV_PREFIX_PROPERTY, ENV_PREFIX_DEFAULT);
ConfigData configData = ConfigData.of()
.yaml(ClassLoader.getSystemResource("application.yaml"))
.env(propertyPrefix)
.sysProps(propertyPrefix)
.build();
ServerConfig serverConfig = configData.getServerConfig("/server");
try {
RatpackServer.of(b-> {
b.serverConfig( serverConfig );
return b.handler(new HandlerFactory(configData)::create);
}).start();
} catch (Exception e ) {
logger.error( "", e );
System.exit(1);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment