/** * @throws CoreException * @throws TimeoutException * @throws ExecutionException * @throws InterruptedException */ private IServer createLiveReloadServer(final String serverName, final boolean injectScript) throws CoreException, InterruptedException, ExecutionException, TimeoutException { final IServer server = WSTUtils.createLiveReloadServer( serverName, "localhost", liveReloadServerPort, injectScript, false); liveReloadServerBehaviour = (LiveReloadServerBehaviour) WSTUtils.findServerBehaviour(server); assertThat(liveReloadServerBehaviour).isNotNull(); liveReloadServer = liveReloadServerBehaviour.getServer(); assertThat(liveReloadServer).isNotNull(); assertThat(liveReloadServer.canStart(ILaunchManager.RUN_MODE).isOK()).isTrue(); return liveReloadServer; }
private void startProxy(final IServer startedServer) { // re-start exiting proxy id already exist if (proxyServers.containsKey(startedServer)) { final LiveReloadProxyServer proxyServer = proxyServers.get(startedServer); try { proxyServer.start(); } catch (Exception e) { Logger.error( "Failed to start LiveReload Proxy on port " + proxyServer.getConnectors()[0].getPort() + " for server " + startedServer.getName(), e); } } // create a new proxy else { final int targetPort = WSTUtils.getWebPort(startedServer); if (targetPort != -1) { try { // now, let's init and start the embedded jetty proxy server // from the // server attributes final boolean allowRemoteConnections = isRemoteConnectionsAllowed(); final boolean enableScriptInjection = isScriptInjectionEnabled(); final String proxyHost = getProxyHost(); final int proxyPort = getProxyPort(startedServer); final LiveReloadProxyServer proxyServer = new LiveReloadProxyServer( proxyHost, proxyPort, startedServer.getHost(), targetPort, websocketPort, allowRemoteConnections, enableScriptInjection); proxyServers.put(startedServer, proxyServer); final JettyServerRunner proxyRunner = JettyServerRunner.start(proxyServer); proxyRunners.put(startedServer, proxyRunner); } catch (Exception e) { Logger.error( "Failed to create or start LiveReload proxy for server " + startedServer.getName(), e); } } } }