diff options
Diffstat (limited to 'src/main/java/org/traccar/schedule/ScheduleManager.java')
-rw-r--r-- | src/main/java/org/traccar/schedule/ScheduleManager.java | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/src/main/java/org/traccar/schedule/ScheduleManager.java b/src/main/java/org/traccar/schedule/ScheduleManager.java index 742428fd8..fd8171148 100644 --- a/src/main/java/org/traccar/schedule/ScheduleManager.java +++ b/src/main/java/org/traccar/schedule/ScheduleManager.java @@ -20,6 +20,9 @@ import org.traccar.LifecycleObject; import jakarta.inject.Inject; import jakarta.inject.Singleton; +import org.traccar.config.Config; +import org.traccar.config.Keys; + import java.util.concurrent.Executors; import java.util.concurrent.ScheduledExecutorService; import java.util.stream.Stream; @@ -28,11 +31,13 @@ import java.util.stream.Stream; public class ScheduleManager implements LifecycleObject { private final Injector injector; + private final boolean secondary; private ScheduledExecutorService executor; @Inject - public ScheduleManager(Injector injector) { + public ScheduleManager(Injector injector, Config config) { this.injector = injector; + secondary = config.getBoolean(Keys.BROADCAST_SECONDARY); } @Override @@ -46,7 +51,12 @@ public class ScheduleManager implements LifecycleObject { TaskReports.class, TaskDeviceInactivityCheck.class, TaskWebSocketKeepalive.class) - .forEachOrdered(task -> injector.getInstance(task).schedule(executor)); + .forEachOrdered(taskClass -> { + var task = injector.getInstance(taskClass); + if (task.multipleInstances() || !secondary) { + task.schedule(executor); + } + }); } @Override |