diff --git a/server/src/main/config/application.properties b/server/src/main/config/application.properties index 02931dd7..a30b5c50 100644 --- a/server/src/main/config/application.properties +++ b/server/src/main/config/application.properties @@ -27,10 +27,14 @@ spring.freemarker.suffix = .ftl #openoffice或LibreOffice home路径 #office.home = C:\\Program Files (x86)\\OpenOffice 4 office.home = ${KK_OFFICE_HOME:default} -## office转换服务的进程数,默认开启两个进程 +## office转换服务的端口,默认开启两个进程 office.plugin.server.ports = 2001,2002 ## office 转换服务 task 超时时间,默认五分钟 office.plugin.task.timeout = 5m +#此属性设置office进程在重新启动之前可以执行的最大任务数。0表示无限数量的任务(永远不会重新启动) +office.plugin.task.maxtasksperprocess = 200 +#此属性设置处理任务所允许的最长时间。如果任务的处理时间长于此超时,则此任务将中止,并处理下一个任务。 +office.plugin.task.taskexecutiontimeout = 5m #生成限制 默认不限制 使用方法 (1-5) office.pagerange = ${KK_OFFICE_PAGERANGE:false} #生成水印 默认不启用 使用方法 (kkFileView) diff --git a/server/src/main/java/cn/keking/service/OfficePluginManager.java b/server/src/main/java/cn/keking/service/OfficePluginManager.java index 41aaee9c..1a01128f 100644 --- a/server/src/main/java/cn/keking/service/OfficePluginManager.java +++ b/server/src/main/java/cn/keking/service/OfficePluginManager.java @@ -43,6 +43,12 @@ public class OfficePluginManager { @Value("${office.plugin.task.timeout:5m}") private String timeOut; + @Value("${office.plugin.task.taskexecutiontimeout:5m}") + private String taskExecutionTimeout; + + @Value("${office.plugin.task.maxtasksperprocess:5}") + private int maxTasksPerProcess; + /** * 启动Office组件进程 */ @@ -60,10 +66,13 @@ public class OfficePluginManager { String[] portsString = serverPorts.split(","); int[] ports = Arrays.stream(portsString).mapToInt(Integer::parseInt).toArray(); long timeout = DurationStyle.detectAndParse(timeOut).toMillis(); + long taskexecutiontimeout = DurationStyle.detectAndParse(taskExecutionTimeout).toMillis(); officeManager = LocalOfficeManager.builder() .officeHome(officeHome) .portNumbers(ports) .processTimeout(timeout) + .maxTasksPerProcess(maxTasksPerProcess) + .taskExecutionTimeout(taskexecutiontimeout) .build(); officeManager.start(); InstalledOfficeManagerHolder.setInstance(officeManager);