Created
February 9, 2015 00:48
-
-
Save arthurtsang/d1c77f7a84443d893646 to your computer and use it in GitHub Desktop.
Ratpack 0.9.13 main
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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