From a6561017739121b38b029a1ab76758be5858d3e7 Mon Sep 17 00:00:00 2001 From: Vitaly Litvak Date: Sat, 7 May 2016 14:58:42 +0300 Subject: [PATCH] Start movement detector in data service only after migrations complete --- .../java/org/traccar/web/server/model/DataServiceImpl.java | 5 +++++ .../java/org/traccar/web/server/model/MovementDetector.java | 3 +++ 2 files changed, 8 insertions(+) diff --git a/src/main/java/org/traccar/web/server/model/DataServiceImpl.java b/src/main/java/org/traccar/web/server/model/DataServiceImpl.java index b889ecb1..e72488ea 100644 --- a/src/main/java/org/traccar/web/server/model/DataServiceImpl.java +++ b/src/main/java/org/traccar/web/server/model/DataServiceImpl.java @@ -76,6 +76,11 @@ public void init() throws ServletException { } catch (Exception e) { throw new RuntimeException("Unable to perform DB migrations", e); } + + /** + * Start movement detector + */ + movementDetector.start(); } EntityManager getSessionEntityManager() { diff --git a/src/main/java/org/traccar/web/server/model/MovementDetector.java b/src/main/java/org/traccar/web/server/model/MovementDetector.java index 6469e326..42d18155 100644 --- a/src/main/java/org/traccar/web/server/model/MovementDetector.java +++ b/src/main/java/org/traccar/web/server/model/MovementDetector.java @@ -43,6 +43,9 @@ public class MovementDetector extends ScheduledTask { @Inject public MovementDetector(Provider entityManagerProvider) { this.entityManagerProvider = entityManagerProvider; + } + + public void start() { scheduler.scheduleWithFixedDelay(this, 0, 1, TimeUnit.MINUTES); }