Skip to content

Commit

Permalink
fix #967 (#968)
Browse files Browse the repository at this point in the history
  • Loading branch information
lookshe authored Mar 4, 2024
1 parent 5e9c030 commit 179152c
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions src/main/java/mServer/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@
import mServer.tool.MserverDatumZeit;
import mServer.tool.MserverLog;

import java.time.LocalDateTime;
import java.time.temporal.ChronoUnit;

public class Main {

public Main() {
Expand Down Expand Up @@ -88,11 +91,15 @@ public static void main(String[] args) {
}

private static void runServer(String[] ar) throws InterruptedException {
LocalDateTime beforeRun = LocalDateTime.now().truncatedTo(ChronoUnit.DAYS);
while (new MServer(ar).starten()) {
long timeToSleep = (MserverDatumZeit.getSecondsUntilNextDay() + 120) * 1000; // 0:02
MserverLog.systemMeldung("Schlafenlegen bis zum nächsten Tag (" + timeToSleep + "ms)");
Thread.sleep(timeToSleep);
MserverLog.systemMeldung("Neustart der Suche");
if (!LocalDateTime.now().truncatedTo(ChronoUnit.DAYS).isAfter(beforeRun)) { // do not sleep if day changed
long timeToSleep = (MserverDatumZeit.getSecondsUntilNextDay() + 120) * 1000; // 0:02
MserverLog.systemMeldung("Schlafenlegen bis zum nächsten Tag (" + timeToSleep + "ms)");
Thread.sleep(timeToSleep);
MserverLog.systemMeldung("Neustart der Suche");
}
beforeRun = LocalDateTime.now().truncatedTo(ChronoUnit.DAYS);
}
}

Expand Down

0 comments on commit 179152c

Please sign in to comment.