Skip to content

Commit e9946a0

Browse files
committed
Add configuration properties guide.sync.model in dss-guide-server.properties
1 parent 2051812 commit e9946a0

File tree

3 files changed

+20
-12
lines changed

3 files changed

+20
-12
lines changed

conf/dss-guide-server.properties

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,3 +51,5 @@ host.gitbook.path=/appcom/Install/ApacheInstall/gitbook_books
5151
target.gitbook.path=/appcom/Install/ApacheInstall
5252
#SUMMARY.md ignore absolve
5353
summary.ignore.model=km
54+
#sync model include: gitbook or database
55+
guide.sync.model=gitbook

dss-apps/dss-user-guide/dss-user-guide-server/src/main/java/com/webank/wedatasphere/dss/guide/server/conf/GuideConf.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,6 @@ public interface GuideConf {
1616

1717
CommonVars<String> SUMMARY_IGNORE_MODEL = CommonVars.apply("summary.ignore.model","km");
1818

19+
CommonVars<String> GUIDE_SYNC_MODEL = CommonVars.apply("guide.sync.model","gitbook");
20+
1921
}

dss-apps/dss-user-guide/dss-user-guide-server/src/main/java/com/webank/wedatasphere/dss/guide/server/restful/KnowledgeGuideAdminRestful.java

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@ public class KnowledgeGuideAdminRestful {
4949

5050
private final static String SHELL_COMMAND_HOST_IP = "hostname -i";
5151

52+
private final static String MODEL_GITBOOK_SYNC = "gitbook";
53+
5254

5355
/**
5456
* 知识库目录接口
@@ -210,20 +212,22 @@ public void syncKnowledge() {
210212
logger.info("开始执行定时任务...");
211213
Utils.defaultScheduler().scheduleAtFixedRate(() -> {
212214
try {
213-
String hostIp = ShellUtils.callShellQuery(SHELL_COMMAND_HOST_IP);
214-
//如果不是当前节点,则需要拷贝文件
215-
if (!StringUtils.equals(hostIp, GuideConf.HOST_IP_ADDRESS.getValue())) {
216-
//判断文件是否存在
217-
boolean flag = FileUtils.fileExist(savePath);
218-
if (flag) {
219-
//删除文件
220-
ShellUtils.callShellByExec(delMkdir);
215+
if (StringUtils.equals(GuideConf.GUIDE_SYNC_MODEL.getValue(), MODEL_GITBOOK_SYNC)) {
216+
String hostIp = ShellUtils.callShellQuery(SHELL_COMMAND_HOST_IP);
217+
//如果不是当前节点,则需要拷贝文件
218+
if (!StringUtils.equals(hostIp, GuideConf.HOST_IP_ADDRESS.getValue())) {
219+
//判断文件是否存在
220+
boolean flag = FileUtils.fileExist(savePath);
221+
if (flag) {
222+
//删除文件
223+
ShellUtils.callShellByExec(delMkdir);
224+
}
225+
//拷贝文件到相应节点
226+
ShellUtils.callShellByExec(scpCommand);
221227
}
222-
//拷贝文件到相应节点
223-
ShellUtils.callShellByExec(scpCommand);
224228
}
225-
//guideCatalogService.syncKnowledge(summaryPath,GuideConf.SUMMARY_IGNORE_MODEL.getValue());
226-
//guideGroupService.asyncGuide(summaryPath,GuideConf.SUMMARY_IGNORE_MODEL.getValue());
229+
guideCatalogService.syncKnowledge(summaryPath, GuideConf.SUMMARY_IGNORE_MODEL.getValue());
230+
guideGroupService.asyncGuide(summaryPath, GuideConf.SUMMARY_IGNORE_MODEL.getValue());
227231
} catch (Exception e) {
228232
logger.error("定时任务执行异常:" + e);
229233
throw new RuntimeException(e);

0 commit comments

Comments
 (0)