Skip to content

Commit

Permalink
系统优化
Browse files Browse the repository at this point in the history
Signed-off-by: xxx <x@x.x>
  • Loading branch information
xxx committed Jan 6, 2018
1 parent 171c5a4 commit 59b47b6
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 16 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@
地址 | 扫描间隔
-------- | ---
https://global.ishadowx.net/ | 3 小时
https://doub.io/sszhfx/ | 3 小时
https://freess.cx/ | 5 小时
https://doub.io/sszhfx/ | 6 小时
https://freess.cx/ | 12 小时


#### TO DO
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@
@Slf4j
@Service
public class DoubCrawlerServiceImpl extends ShadowSocksCrawlerService {
// 网站刷新时间(抓取SS信息间隔时间)
public static final int REFRESH_TIME = 3 * 60 * 60 * 1000;
// 目标网站 URL
private static final String TARGET_URL = "https://doub.io/sszhfx/";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@
@Slf4j
@Service
public class FreeSS_EasyToUseCrawlerServiceImpl extends ShadowSocksCrawlerService {
// 网站刷新时间(抓取SS信息间隔时间)
public static final int REFRESH_TIME = 5 * 60 * 60 * 1000;
// 目标网站 URL
private static final String TARGET_URL = "https://freess.cx/";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@
@Slf4j
@Service("iShadowCrawlerServiceImpl")
public class IShadowCrawlerServiceImpl extends ShadowSocksCrawlerService {
// 网站刷新时间(抓取SS信息间隔时间)
public static final int REFRESH_TIME = 3 * 60 * 60 * 1000;
// 目标网站 URL
private static final String TARGET_URL = "https://global.ishadowx.net/";

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package com.example.ShadowSocksShare.service.listener;

import com.example.ShadowSocksShare.service.tasks.ShadowSocksTasks;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.event.ContextRefreshedEvent;
import org.springframework.context.event.EventListener;
import org.springframework.stereotype.Component;

/**
* 系统启动 监听事件
*/
@Slf4j
@Component
public class ApplicationStartupListener {
@Autowired
private ShadowSocksTasks shadowSocksTasks;


/**
* 系统启动 监听事件
*/
@EventListener
public void handleOrderStateChange(ContextRefreshedEvent contextRefreshedEvent) {
log.debug(contextRefreshedEvent.toString());
shadowSocksTasks.runAll();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,24 +32,27 @@ public class ShadowSocksTasks {
@Qualifier("freeSS_EasyToUseCrawlerServiceImpl")
private ShadowSocksCrawlerService freeSS_EasyToUseCrawlerServiceImpl; // https://freess.cx/#portfolio-preview

/**
* 第一次延迟 10 秒执行,之后每 fixedRate 执行一次
*/
@Scheduled(initialDelay = 10 * 1000, fixedRate = IShadowCrawlerServiceImpl.REFRESH_TIME)
@Scheduled(cron = "0 10 */3 * * ?")
public void iShadowCrawler() {
shadowSocksSerivce.crawlerAndSave(iShadowCrawlerServiceImpl);
}

@Scheduled(initialDelay = 20 * 1000, fixedRate = DoubCrawlerServiceImpl.REFRESH_TIME)
@Scheduled(cron = "0 10 */6 * * ?")
public void doubCrawler() {
shadowSocksSerivce.crawlerAndSave(doubCrawlerServiceImpl);
}

@Scheduled(initialDelay = 30 * 1000, fixedRate = FreeSS_EasyToUseCrawlerServiceImpl.REFRESH_TIME)
public void FreeSS_EasyToUseCrawler() {
@Scheduled(cron = "0 10 */12 * * ?")
public void freeSS_EasyToUseCrawler() {
shadowSocksSerivce.crawlerAndSave(freeSS_EasyToUseCrawlerServiceImpl);
}

public void runAll() {
iShadowCrawler();
doubCrawler();
freeSS_EasyToUseCrawler();
}

/**
* SS 有效性检查,每 1 小时
*/
Expand All @@ -62,7 +65,7 @@ public void checkValid() {
/**
* 为防止 herokuapp 休眠,每 10 分钟访问一次
*/
@Scheduled(initialDelay = 10 * 60 * 1000, fixedRate = 10 * 60 * 1000)
@Scheduled(cron = "0 */20 * * * ?")
public void monitor() throws IOException {
Jsoup.connect("https://shadowsocks-share.herokuapp.com/subscribe").get();
}
Expand Down

0 comments on commit 59b47b6

Please sign in to comment.