mirror of
https://github.com/Athou/commafeed.git
synced 2026-09-26 05:54:41 +00:00
wait for tasks to complete when shutting down
This commit is contained in:
@@ -6,16 +6,23 @@ import java.util.concurrent.ScheduledExecutorService;
|
||||
|
||||
import jakarta.inject.Singleton;
|
||||
|
||||
import io.quarkus.arc.All;
|
||||
import com.commafeed.CommaFeedConfiguration;
|
||||
import com.google.common.util.concurrent.MoreExecutors;
|
||||
|
||||
import io.quarkus.arc.All;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
@Slf4j
|
||||
@Singleton
|
||||
public class TaskScheduler {
|
||||
|
||||
private final List<ScheduledTask> tasks;
|
||||
private final CommaFeedConfiguration config;
|
||||
private final ScheduledExecutorService executor;
|
||||
|
||||
public TaskScheduler(@All List<ScheduledTask> tasks) {
|
||||
public TaskScheduler(@All List<ScheduledTask> tasks, CommaFeedConfiguration config) {
|
||||
this.tasks = tasks;
|
||||
this.config = config;
|
||||
this.executor = Executors.newScheduledThreadPool(tasks.size());
|
||||
}
|
||||
|
||||
@@ -24,6 +31,6 @@ public class TaskScheduler {
|
||||
}
|
||||
|
||||
public void stop() {
|
||||
executor.shutdownNow();
|
||||
MoreExecutors.shutdownAndAwaitTermination(executor, config.shutdownTimeout());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user