We will be migrating from Ask to Discourse on the first week of August, read the details here

Ask Your Question
0

How to start independent LO instance (avoid unoconv aborts)

asked 2021-01-29 21:00:34 +0200

jimav gravatar image

updated 2021-06-30 14:03:50 +0200

Alex Kemp gravatar image

Is it possible to start a separate, independent instance of LO which has no interaction with an already-running LO process?

Doing so is, I think, necessary to fix a forever-standing bug in the linux unoconv batch-convertion script. unoconv works by sending commands through a socket to a separate LO process. If it can't connect to an existing LO process for some reason, it tries to start it's own LO process.

But when it starts its own, the LO process it starts immediately exits (with zero status) without doing anything if another LO process is running. This causes unoconv to abort.

Here is what unoconv runs to start its "own" instance:

/usr/lib/libreoffice/program/soffice.bin --headless --invisible --nocrashreport --nodefault --nofirststartwizard --nologo --norestore --accept='socket,host=127.0.0.1,port=2002,tcpNoDelay=1;urp;StarOffice.ComponentContext'

If you run this interactively with no previous LO process running, it just sits there as you might expect (doing nothing but listening on the indicated socket/port).

But if you first open a spreadsheet with localc /path/to/something.xlsx and then run the above command in another terminal, the supposedly-second LO process exits immediately, i.e. it does not stick around and listen. Even if you specify a different port number in the --accept string.

Side note: There remains a question as to why the existing interactive LO process can not work with batch unoconv commands. I don't know the answer. It seems to work sometimes, but often fails immediately after LO has freshly started and opened a spreadsheet interactively (as if by default there is no listener, which might be the case). Anyway, I don't think this should matter if unoconv can reliably start its own, independent instance of LO.

edit retag flag offensive close merge delete

Comments

Lupp gravatar imageLupp ( 2021-01-29 22:11:43 +0200 )edit

2 Answers

Sort by » oldest newest most voted
1

answered 2021-01-29 23:03:54 +0200

karolus gravatar image

for serious reasons it isnt possible to run more than one instance on the same $user_configuration so you need for an second indepentend instance an addional argument: -env:UserInstallation=file:///home/<you>/...

edit flag offensive delete link more
0

answered 2021-01-30 19:56:59 +0200

jimav gravatar image

updated 2021-01-30 20:20:20 +0200

Thanks @karolus !

Here's a wrapper shell script for unoconv which uses a temporary config dir to avoid conflicts. This way unoconv seems to work reliably regardless of what normal LO instances are doing:

#!/bin/sh
set -e -u

# Wrapper for unoconv which make LibreOffice use a separate
# temporary user-config dir to avoid unoconv aborts when
# LO is in use interactively.
#
# https://ask.libreoffice.org/en/question/290306/how-to-start-independent-lo-instance-process

tempdir=$(mktemp -d /tmp/myuno.XXXXX)
cleanup() { [ -z "${tempdir:-}" ] || rm -rf "$tempdir"; }

# Remove tempdir when terminating
trap 'e=$?; cleanup; exit $e' EXIT
for sig in HUP INT QUIT KILL ; do
  trap "cleanup; trap $sig; kill -$sig \$\$" $sig
done

UserInstallation="file://$tempdir" unoconv ${1+"$@"}
edit flag offensive delete link more
Login/Signup to Answer

Question Tools

1 follower

Stats

Asked: 2021-01-29 21:00:34 +0200

Seen: 67 times

Last updated: Jan 30