Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix #967 #968

Merged
merged 1 commit into from
Mar 4, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading