!263 新增office转换 超时属性功能

Merge pull request !263 from 高雄/master
This commit is contained in:
kailing 2024-02-21 03:10:58 +00:00 committed by Gitee
commit 211df6965f
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
2 changed files with 14 additions and 1 deletions

View File

@ -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)

View File

@ -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);