Skip to content

Commit

Permalink
7.5.18
Browse files Browse the repository at this point in the history
- added 10min timeout to Server.stop() and added kill() if that timeout is reached to prevent infinite waiting if failing to stop.
  • Loading branch information
Osiris-Team committed Apr 27, 2024
1 parent 4727585 commit 1964edd
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

<groupId>com.osiris.autoplug.client</groupId>
<artifactId>autoplug-client</artifactId>
<version>7.5.17</version>
<version>7.5.18</version>
<packaging>jar</packaging>

<name>AutoPlug-Client</name>
Expand Down
14 changes: 10 additions & 4 deletions src/main/java/com/osiris/autoplug/client/Server.java
Original file line number Diff line number Diff line change
Expand Up @@ -168,11 +168,10 @@ public static synchronized void stop() throws IOException, InterruptedException,
seconds++;
if (seconds >= maxSeconds) {
if (inKillMode)
throw new IOException("Failed to stop (after 10 minutes) and kill (after 1 minute) server.");
throw new IOException("Failed to stop and kill server (waited 20 minutes in total).");
inKillMode = true;
AL.warn("10 minutes have passed and the server is still running, killing it...");
kill();
seconds -= 60;
}
}

Expand All @@ -197,14 +196,21 @@ public static synchronized boolean kill() {
AL.warn("Server is not running!");
}

while (isRunning()) {
int maxSeconds = 60 * 10;
int seconds = 0;
while (Server.isRunning()) {
Thread.sleep(1000);
seconds++;
if (seconds >= maxSeconds) {
throw new RuntimeException("Failed to kill server (waited 10 minutes).");
}
}
AL.info("Server killed!");
//isKill.set(false); // Gets set to false in thread alive checker
return true;

} catch (InterruptedException e) {
AL.warn(e);
//isKill.set(false);
return false;
}
}
Expand Down

0 comments on commit 1964edd

Please sign in to comment.