Skip to content

Commit

Permalink
fixed port issue
Browse files Browse the repository at this point in the history
  • Loading branch information
albogdano committed May 12, 2017
1 parent 2bedcad commit ec5f0d8
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/main/java/com/erudika/scoold/ScooldServer.java
Original file line number Diff line number Diff line change
Expand Up @@ -130,11 +130,18 @@ public static void main(String[] args) {
* @return the host URL of this Scoold server
*/
public static String getServerURL() {
String defaultHost = "http://localhost:" + Config.getConfigInt("port", 8080);
String defaultHost = "http://localhost:" + getServerPort();
String host = Config.IN_PRODUCTION ? Config.getConfigParam("host_url", defaultHost) : defaultHost;
return StringUtils.removeEnd(host, "/");
}

/**
* @return the port of this Scoold server
*/
public static int getServerPort() {
return NumberUtils.toInt(System.getProperty("server.port"), Config.getConfigInt("port", 8080));
}

@Bean
public WebMvcConfigurerAdapter baseConfigurerBean(@Named final ScooldRequestInterceptor sri) {
return new WebMvcConfigurerAdapter() {
Expand Down Expand Up @@ -194,8 +201,7 @@ public Emailer scooldEmailerBean() {
@Bean
public EmbeddedServletContainerFactory jettyConfigBean() {
JettyEmbeddedServletContainerFactory jef = new JettyEmbeddedServletContainerFactory();
int defaultPort = Config.getConfigInt("port", 8080);
jef.setPort(NumberUtils.toInt(System.getProperty("server.port"), defaultPort));
jef.setPort(getServerPort());
logger.info("Listening on port {}...", jef.getPort());
return jef;
}
Expand Down

0 comments on commit ec5f0d8

Please sign in to comment.