From d5209bee228f34c3c667b09f5ab512cf43969a30 Mon Sep 17 00:00:00 2001 From: Martin Lippert Date: Mon, 7 Sep 2015 10:12:41 +0200 Subject: [PATCH] re-use local server port when re-starting with ngrok if app is already running --- .../boot/dash/model/BootProjectDashElement.java | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/plugins/org.springframework.ide.eclipse.boot.dash/src/org/springframework/ide/eclipse/boot/dash/model/BootProjectDashElement.java b/plugins/org.springframework.ide.eclipse.boot.dash/src/org/springframework/ide/eclipse/boot/dash/model/BootProjectDashElement.java index b4eea58a4f..a7a7145aec 100644 --- a/plugins/org.springframework.ide.eclipse.boot.dash/src/org/springframework/ide/eclipse/boot/dash/model/BootProjectDashElement.java +++ b/plugins/org.springframework.ide.eclipse.boot.dash/src/org/springframework/ide/eclipse/boot/dash/model/BootProjectDashElement.java @@ -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) { @@ -474,7 +478,7 @@ else if (RunState.DEBUGGING.equals(runMode)) { } Map extraAttributes = new HashMap(); - 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);