zoukankan      html  css  js  c++  java
  • 解决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;
        }
  • 相关阅读:
    jmeter参数化关联
    电商
    mysql联查
    购物车
    冒泡排序、二分查找、选择排序、斐波那契
    python数据转换/9*9表/for循环
    python三角形
    mysql语句
    Selenium 8
    Selenium 7
  • 原文地址:https://www.cnblogs.com/RivenLw/p/10477639.html
Copyright © 2011-2022 走看看