From 1f6a134ccc5bb9a61ae7b0b01d4b42452e893028 Mon Sep 17 00:00:00 2001 From: Lennart Regebro Date: Fri, 11 Oct 2024 10:42:48 +0200 Subject: [PATCH] Use soffice by default, fallback to libreoffice (#139) Co-authored-by: Lennart Regebro --- CHANGES.rst | 4 ++-- src/unoserver/server.py | 19 ++++++++++++++++--- 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/CHANGES.rst b/CHANGES.rst index f0177a2..904a8b0 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -1,8 +1,8 @@ 2.3 (unreleased) ---------------- -- Nothing changed yet. - +- By default it will now use the `soffice`` executable instead of `libreoffice`, + as I had a problem with it using 100% load when started as `libreoffice`. 2.3b1 (2024-10-09) ------------------ diff --git a/src/unoserver/server.py b/src/unoserver/server.py index 152bbc4..b4656fe 100644 --- a/src/unoserver/server.py +++ b/src/unoserver/server.py @@ -3,6 +3,7 @@ import argparse import logging import os +import shutil import signal import socket import subprocess @@ -252,8 +253,8 @@ def main(): parser.add_argument("--daemon", action="store_true", help="Deamonize the server") parser.add_argument( "--executable", - default="libreoffice", - help="The path to the LibreOffice executable", + default=None, + help="The path to the LibreOffice executable, defaults to looking in the path", ) parser.add_argument( "--user-installation", @@ -292,10 +293,22 @@ def main(): user_installation, ) + if args.executable is not None: + executable = args.executable + else: + # Find the executable automatically. I had problems with + # LibreOffice using 100% if started with the libreoffice + # executable, so by default try soffice first. Also throwing + # ooffice in there as a fallback, I don't think it's used any + # more, but it doesn't hurt to have it there. + for name in ("soffice", "libreoffice", "ooffice"): + if (executable := shutil.which(name)) is not None: + break + # If it's daemonized, this returns the process. # It returns 0 of getting killed in a normal way. # Otherwise it returns 1 after the process exits. - process = server.start(executable=args.executable) + process = server.start(executable=executable) if process is None: return 2 pid = process.pid