Skip to content

Commit

Permalink
项目优化
Browse files Browse the repository at this point in the history
  • Loading branch information
xxx committed Mar 4, 2018
1 parent 0115369 commit 4550d21
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ public ShadowSocksEntity getShadowSocks() {
options.addArguments("--headless");
options.addArguments("--disable-gpu");
options.addArguments("--no-sandbox");
options.addArguments("--remote-debugging-port=9222");
// options.addArguments("--remote-debugging-port=9222");
}

if (ssProxyEnable) {
Expand Down
20 changes: 20 additions & 0 deletions src/main/java/com/example/ShadowSocksShare/web/MainController.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,14 @@
import com.example.ShadowSocksShare.domain.ShadowSocksDetailsEntity;
import com.example.ShadowSocksShare.domain.ShadowSocksEntity;
import com.example.ShadowSocksShare.service.CountSerivce;
import com.example.ShadowSocksShare.service.ShadowSocksCrawlerService;
import com.example.ShadowSocksShare.service.ShadowSocksSerivce;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.google.zxing.WriterException;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort;
import org.springframework.data.web.PageableDefault;
Expand All @@ -34,6 +37,10 @@ public class MainController {
private ShadowSocksSerivce shadowSocksSerivceImpl;
@Autowired
private CountSerivce countSerivce;
@Autowired
private ShadowSocksSerivce shadowSocksSerivce;
@Autowired
private ApplicationContext appContext;

/**
* 首页
Expand Down Expand Up @@ -101,4 +108,17 @@ public ResponseEntity<byte[]> createQRCode(long id, String text, int width, int
public ResponseEntity<String> count() {
return ResponseEntity.ok().body(String.valueOf(countSerivce.get()));
}

@RequestMapping(value = "/run")
@ResponseBody
public ResponseEntity<String> run(String name) {
if (StringUtils.isNotBlank(name)) {
Object bean = appContext.getBean(name);

if (bean instanceof ShadowSocksCrawlerService) {
shadowSocksSerivce.crawlerAndSave(ShadowSocksCrawlerService.class.cast(bean));
}
}
return ResponseEntity.ok().body("OK...");
}
}

0 comments on commit 4550d21

Please sign in to comment.