28 lines
1.2 KiB
Java
28 lines
1.2 KiB
Java
package games.dmg.spigotquestboard;
|
|
|
|
import java.nio.file.Files;
|
|
import java.nio.file.Path;
|
|
import java.util.concurrent.Executors;
|
|
import java.util.logging.Logger;
|
|
|
|
/** Forked-JVM fixture: System.exit does not wait for a non-daemon writer without our hook. */
|
|
public final class QuestShutdownProcess {
|
|
private QuestShutdownProcess() { }
|
|
public static void main(String[] args) {
|
|
Thread main = Thread.currentThread();
|
|
QuestRuntimeScheduler runtime = new QuestRuntimeScheduler(
|
|
Executors.newSingleThreadExecutor(Thread.ofPlatform().daemon(false).factory()),
|
|
task -> { throw new AssertionError("No Bukkit callbacks may be needed during final disk drain"); },
|
|
() -> Thread.currentThread() == main);
|
|
runtime.installShutdownBoundary(Logger.getLogger("shutdown-process"));
|
|
runtime.worker().execute(() -> {
|
|
try {
|
|
Thread.sleep(300);
|
|
Files.writeString(Path.of(args[0]), "accepted escrow persisted");
|
|
} catch (Exception exception) { throw new AssertionError(exception); }
|
|
});
|
|
runtime.closeRecovering(() -> true);
|
|
System.exit(0);
|
|
}
|
|
}
|