Skip to content

Commit

Permalink
further logging
Browse files Browse the repository at this point in the history
  • Loading branch information
maybeec committed Apr 28, 2021
1 parent ab24099 commit 686b733
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
2 changes: 1 addition & 1 deletion cobigen-eclipse/cobigen-eclipse/.classpath
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<classpathentry exported="true" kind="lib" path="lib/commons-jxpath.jar"/>
<classpathentry exported="true" kind="lib" path="lib/commons-lang3.jar"/>
<classpathentry exported="true" kind="lib" path="lib/core-api.jar"/>
<classpathentry exported="true" kind="lib" path="lib/core.jar"/>
<classpathentry exported="true" kind="lib" path="lib/core.jar" sourcepath="/core"/>
<classpathentry exported="true" kind="lib" path="lib/dozer.jar"/>
<classpathentry exported="true" kind="lib" path="lib/guava.jar"/>
<classpathentry exported="true" kind="lib" path="lib/jackson-annotations.jar"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public class ExternalProcess {
private final String serverVersion;

/** Port used for connecting to the server */
public int port = 5000;
private int port = 5000;

/** Host name of the server, by default is localhost */
private String hostName = "localhost";
Expand Down Expand Up @@ -256,23 +256,28 @@ private boolean startServer(int currentTry) {
LOG.info("Waiting process to be alive for {}s", 100 * retry / 1000d);
}
if (retry > 50) {
LOG.error("Server could not be started at port {}", port);
return false;
}

LOG.info("Server started at port {}", port);
return true;
} catch (Throwable e) {
BindException bindException = ExceptionUtil.getCause(e, BindException.class);
ConnectException connectException = ExceptionUtil.getCause(e, ConnectException.class);
if (bindException != null || connectException != null) {
process.getProcess().destroyForcibly();
try {
process.getProcess().destroyForcibly().waitFor();
} catch (InterruptedException e1) {
LOG.error("Interrupted wait for process termination to complete", e1);
}
int newPort = aquireNewPort();
LOG.debug("Port {} already in use, trying port {}", port, newPort);
port = newPort;
return startServer(currentTry++);
}
throw new CobiGenRuntimeException("Unable to start the exe/server", e);
}

LOG.info("Server started at port {}", port);
return true;
}

/**
Expand Down

0 comments on commit 686b733

Please sign in to comment.