Skip to content

Commit 2e28a69

Browse files
authored
chore: align startup message to include port number (#195)
To be compliant with the behavior of glsp-server-node, the startup message has to include the port of the socket. Fixes eclipse-glsp/glsp#825 * Print which random available port is used if port 0 is specified If `-p 0` is specified as command line argument, the GLSP server uses an available port assigned by the OS. This patch - adjusts the startup message accordingly - adds the startup message to the WebsocketServerLauncher - jdk17-compatibility: adjust the fatjar to unsign jars, because signed jars may not be repacked - adds a step to the jenkinsfile to build the fatjar Signed-off-by: Olaf Lessenich <olessenich@eclipsesource.com>
1 parent 68720d9 commit 2e28a69

File tree

4 files changed

+28
-5
lines changed

4 files changed

+28
-5
lines changed

Jenkinsfile

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,14 @@ pipeline {
2727
}
2828
}
2929

30+
stage ('Build: fatjar') {
31+
steps {
32+
timeout(30) {
33+
sh 'mvn clean verify -Pfatjar -B -Dcheckstyle.skip -DskipTests'
34+
}
35+
}
36+
}
37+
3038
stage('Checkstyle') {
3139
steps {
3240
timeout(30) {

examples/org.eclipse.glsp.example.workflow/pom.xml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,9 @@
174174
<exclude>**/*.mwe2</exclude>
175175
<exclude>**/*.xtext</exclude>
176176
<exclude>**/*.xtextbin</exclude>
177+
<exclude>META-INF/*.SF</exclude>
178+
<exclude>META-INF/*.RSA</exclude>
179+
<exclude>META-INF/*.INF</exclude>
177180
</excludes>
178181
</filter>
179182
</filters>
@@ -195,4 +198,4 @@
195198
</profile>
196199
</profiles>
197200

198-
</project>
201+
</project>

plugins/org.eclipse.glsp.server.websocket/src/org/eclipse/glsp/server/websocket/WebsocketServerLauncher.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
import com.google.inject.Module;
3333

3434
public class WebsocketServerLauncher extends GLSPServerLauncher {
35+
public static final String START_UP_COMPLETE_MSG = "[GLSP-Server]:Startup completed. Accepting requests on port:";
3536
private static Logger LOGGER = LogManager.getLogger(WebsocketServerLauncher.class);
3637
protected Server server;
3738
protected final String endpointPath;
@@ -50,11 +51,14 @@ public WebsocketServerLauncher(final ServerModule serverModule, final String end
5051
this.websocketLogLevel = websocketLogLevel;
5152
}
5253

54+
protected String getStartupCompleteMessage() { return START_UP_COMPLETE_MSG; }
55+
5356
@Override
5457
@SuppressWarnings("checkstyle:IllegalCatch")
55-
public void start(final String hostname, final int port) {
58+
public void start(final String hostname, int port) {
5659
try {
5760
Configurator.setLevel("org.eclipse.jetty", this.websocketLogLevel);
61+
5862
// Setup Jetty Server
5963
server = new Server(new InetSocketAddress(hostname, port));
6064
ServletContextHandler webAppContext;
@@ -77,7 +81,11 @@ public void start(final String hostname, final int port) {
7781
// Start the server
7882
try {
7983
server.start();
84+
if (port == 0) {
85+
port = server.getURI().getPort();
86+
}
8087
LOGGER.info("GLSP server is running and listening on Endpoint : " + server.getURI() + endpointPath);
88+
System.out.println(getStartupCompleteMessage() + port);
8189
server.join();
8290
} catch (Exception exception) {
8391
LOGGER.warn("Shutting down due to exception", exception);

plugins/org.eclipse.glsp.server/src/org/eclipse/glsp/server/launch/SocketGLSPServerLauncher.java

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
import com.google.inject.Module;
4646

4747
public class SocketGLSPServerLauncher extends GLSPServerLauncher {
48-
public static final String START_UP_COMPLETE_MSG = "[GLSP-Server]:Startup completed";
48+
public static final String START_UP_COMPLETE_MSG = "[GLSP-Server]:Startup completed. Accepting requests on port:";
4949
private static Logger LOGGER = LogManager.getLogger(SocketGLSPServerLauncher.class);
5050

5151
private ExecutorService threadPool;
@@ -72,11 +72,15 @@ public void start(final String hostname, final int port) {
7272

7373
protected String getStartupCompleteMessage() { return START_UP_COMPLETE_MSG; }
7474

75-
public Future<Void> asyncRun(final String hostname, final int port)
75+
public Future<Void> asyncRun(final String hostname, int port)
7676
throws IOException, InterruptedException, ExecutionException {
7777
onShutdown = new CompletableFuture<>();
7878

7979
serverSocket = AsynchronousServerSocketChannel.open().bind(new InetSocketAddress(hostname, port));
80+
if (port == 0) {
81+
port = ((InetSocketAddress) serverSocket.getLocalAddress()).getPort();
82+
}
83+
8084
threadPool = Executors.newCachedThreadPool();
8185

8286
CompletionHandler<AsynchronousSocketChannel, Void> handler = new CompletionHandler<>() {
@@ -96,7 +100,7 @@ public void failed(final Throwable exc, final Void attachment) {
96100
LOGGER.info("The GLSP server is ready to accept new client requests on port: " + port);
97101
// Print a message to the output stream that indicates that the start is completed.
98102
// This indicates to the client that the sever process is ready (in an embedded scenario).
99-
System.out.println(getStartupCompleteMessage());
103+
System.out.println(getStartupCompleteMessage() + port);
100104

101105
return onShutdown;
102106
}

0 commit comments

Comments
 (0)