aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/org/traccar/schedule/ScheduleManager.java
diff options
context:
space:
mode:
authorIván Ávalos <avalos@disroot.org>2024-08-03 20:52:00 -0600
committerIván Ávalos <avalos@disroot.org>2024-08-03 20:52:00 -0600
commit55f6d92c09a5b1d8566b53633d07be3d31010d3b (patch)
treeb86bed801b0bbadb72c7e839296dae1d28b12bbb /src/main/java/org/traccar/schedule/ScheduleManager.java
parentc04ad7d48331253c095fc123ded1b00f6ff871d3 (diff)
parent2788174193def918a3a1a5be3bbed24c9613323f (diff)
downloadtrackermap-server-55f6d92c09a5b1d8566b53633d07be3d31010d3b.tar.gz
trackermap-server-55f6d92c09a5b1d8566b53633d07be3d31010d3b.tar.bz2
trackermap-server-55f6d92c09a5b1d8566b53633d07be3d31010d3b.zip
Merge tag 'tags/v6.3'
Diffstat (limited to 'src/main/java/org/traccar/schedule/ScheduleManager.java')
-rw-r--r--src/main/java/org/traccar/schedule/ScheduleManager.java14
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