From d898e412c753c01b80e1b9fc2ab11cce58ce2185 Mon Sep 17 00:00:00 2001
From: xiongxiaoyang <773861846@qq.com>
Date: Mon, 13 Jan 2020 14:26:55 +0800
Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E7=AD=96=E7=95=A5=E4=BC=98?=
 =?UTF-8?q?=E5=8C=96?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 .../books/core/listener/StartListener.java    | 16 +++++++-
 .../core/schedule/UpdateBookSchedule.java     | 39 -------------------
 2 files changed, 15 insertions(+), 40 deletions(-)
 delete mode 100644 novel-front/src/main/java/xyz/zinglizingli/books/core/schedule/UpdateBookSchedule.java

diff --git a/novel-front/src/main/java/xyz/zinglizingli/books/core/listener/StartListener.java b/novel-front/src/main/java/xyz/zinglizingli/books/core/listener/StartListener.java
index f661b68..696d629 100644
--- a/novel-front/src/main/java/xyz/zinglizingli/books/core/listener/StartListener.java
+++ b/novel-front/src/main/java/xyz/zinglizingli/books/core/listener/StartListener.java
@@ -47,7 +47,7 @@ public class StartListener implements ServletContextListener {
                 while (true) {
                     try {
 
-                        log.info("crawlBooks执行中。。。。。。。。。。。。");
+                        log.info("parseBooks执行中。。。。。。。。。。。。");
                         crawlSource.parse();
 
                         Thread.sleep(1000 * 60 * 5);
@@ -57,6 +57,20 @@ public class StartListener implements ServletContextListener {
 
                 }
             }).start();
+
+            new Thread(() -> {
+                while (true) {
+                    try {
+
+                        log.info("updateBooks执行中。。。。。。。。。。。。");
+                        crawlSource.update();
+                        Thread.sleep(1000 * 60 * 10);
+                    } catch (Exception e) {
+                        log.error(e.getMessage(), e);
+                    }
+
+                }
+            }).start();
         }
     }
 
diff --git a/novel-front/src/main/java/xyz/zinglizingli/books/core/schedule/UpdateBookSchedule.java b/novel-front/src/main/java/xyz/zinglizingli/books/core/schedule/UpdateBookSchedule.java
deleted file mode 100644
index 59c9dae..0000000
--- a/novel-front/src/main/java/xyz/zinglizingli/books/core/schedule/UpdateBookSchedule.java
+++ /dev/null
@@ -1,39 +0,0 @@
-package xyz.zinglizingli.books.core.schedule;
-
-
-import lombok.RequiredArgsConstructor;
-import lombok.extern.slf4j.Slf4j;
-import org.springframework.beans.factory.annotation.Value;
-import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
-import org.springframework.scheduling.annotation.Scheduled;
-import org.springframework.stereotype.Service;
-import xyz.zinglizingli.books.core.crawl.BaseCrawlSource;
-import xyz.zinglizingli.books.po.Book;
-import xyz.zinglizingli.books.service.BookService;
-
-import java.util.List;
-
-/**
- * 定时更新
- *
- * @author 11797
- */
-@Service
-@RequiredArgsConstructor
-@Slf4j
-public class UpdateBookSchedule {
-
-    private final BaseCrawlSource crawlSource;
-
-
-    /**
-     * 10分钟更新一次
-     */
-    @Scheduled(fixedRate = 1000 * 60 * 10)
-    public void updateBook() {
-
-        log.info("UpdateBookSchedule。。。。。。。。。。。。");
-
-        crawlSource.update();
-    }
-}