Skip to content
This repository has been archived by the owner on Jul 13, 2022. It is now read-only.

Commit

Permalink
re-use local server port when re-starting with ngrok if app is alread…
Browse files Browse the repository at this point in the history
…y running
  • Loading branch information
martinlippert committed Sep 7, 2015
1 parent 52512bf commit d5209be
Showing 1 changed file with 7 additions and 3 deletions.
Expand Up @@ -454,12 +454,16 @@ else if (RunState.DEBUGGING.equals(runMode)) {
throw new IllegalArgumentException("Restart and expose expects RUNNING or DEBUGGING as 'goal' state");
}

int port = getLivePort();
stopSync();

int freePort = SocketUtil.findFreePort();
if (port <= 0) {
port = SocketUtil.findFreePort();
}

String tunnelName = getName();

NGROKTunnel tunnel = ngrokClient.startTunnel("http", Integer.toString(freePort));
NGROKTunnel tunnel = ngrokClient.startTunnel("http", Integer.toString(port));
NGROKLaunchTracker.add(tunnelName, ngrokClient, tunnel);

if (tunnel == null) {
Expand All @@ -474,7 +478,7 @@ else if (RunState.DEBUGGING.equals(runMode)) {
}

Map<String, String> extraAttributes = new HashMap<String, String>();
extraAttributes.put("spring.boot.prop.server.port", "1" + Integer.toString(freePort));
extraAttributes.put("spring.boot.prop.server.port", "1" + Integer.toString(port));
extraAttributes.put("spring.boot.prop.eureka.instance.hostname", "1" + tunnelURL);
extraAttributes.put("spring.boot.prop.eureka.instance.nonSecurePort", "1" + "80");
extraAttributes.put("spring.boot.prop.eureka.client.service-url.defaultZone", "1" + eurekaInstance);
Expand Down

0 comments on commit d5209be

Please sign in to comment.