• 解决Libreoffice在Linux服务器上,重启Tomcat但是Libreoffice8100端口还一直占用的问题


    解决思路,既然上一个libreoffice没关闭,导致8100端口被占用,那我们就去关闭它。

    在OfficeManager.start();方法之前,使用Linux进程操作工具类,找到之前的libreoffice进程,然后杀掉进程。
    Linux进程操作工具类请看https://www.cnblogs.com/RivenLw/p/10477488.html

    /**
         * 连接LibreOffice.org 并且启动LibreOffice.org
         * 
         * @return
         * @throws Exception 
         */
        public static OfficeManager getOfficeManager() throws Exception {
            
            String osName = System.getProperty("os.name");
            if (Pattern.matches("Linux.*", osName)) {//如果是Linux系统则尝试先结束上次启动的Libreoffice
                String pid = LinuxProcessUtil.getPID("libreoffice");
                logger.info("找到pid="+pid);
                if (StringUtils.isNotEmpty(pid)) {
                    LinuxProcessUtil.closeLinuxProcess(pid);
                }
            }
            
            DefaultOfficeManagerConfiguration config = new DefaultOfficeManagerConfiguration();
            // 设置LibreOffice.org 3的安装目录
            config.setOfficeHome(getOfficeHome());
            // 端口号
            config.setPortNumber(8100);
            config.setTaskExecutionTimeout(1000 * 60 * 25L);
    //         设置任务执行超时为10分钟
            config.setTaskQueueTimeout(1000 * 60 * 60 * 24L);
    //         设置任务队列超时为24小时
            // 启动LibreOffice的服务
            OfficeManager getOfficeManager = config.buildOfficeManager();
            getOfficeManager.start();
            return getOfficeManager;
        }
  • 相关阅读:
    docker 相关
    mongo 连接方式
    Redis 面试题
    Ubuntu如何挂载U盘
    python try异常处理之traceback准确定位哪一行出问题
    Opencv 基础用法
    CentOS 7 安装MongoDB 4.0(yum方式) 简单方便
    linux中pthread_join()与pthread_detach()详解
    C语言线程池 第三方库
    XML文件删除掉注释
  • 原文地址:https://www.cnblogs.com/RivenLw/p/10477639.html
Copyright © 2020-2023  润新知