Hi,
If you are running on an os that ships with systemd, the trick is to make a template unit file (systemd file). In order to run multiple instances of LibreOffice. This can be useful to distribute the load of big convert batches for example. In this example I will show you how to start 3 instances each with there own PID and port.
port 8101, 8102, 8103
Start by testing the exec start command in the terminal. With quotes!!! for env vars.
/usr/lib64/libreoffice/program/soffice.bin -env:SingleAppInstance="false" -env:UserInstallation="file:///tmp/LibO_Process8101" --accept="socket,host=localhost,port=8101;urp;" --headless --norestore
Put the command in a unit file. very important WITHOUT quotes!! on the env options.
vi /lib/systemd/system/libreoffice@.service
# headless soffice instance
[Unit]
Description=Control headless soffice instance %i
After=network.target
[Service]
Type=simple
ExecStart=/usr/lib64/libreoffice/program/soffice.bin -env:SingleAppInstance=false -env:UserInstallation=file:///tmp/LibO_Process%i --accept=socket,host=localhost,port=%i;urp; --headless --norestore
Nice=5
[Install]
WantedBy=multi-user.target
Some side notes:
-
It is very important to NOT use
quotes in a unit (systemd) file.
These files are executed in a non
bash environment and quotes are not
‘interpreted’ deep linux stuff… -
notice the ‘@’ in the file name, it
needs to be there! NAME@.service is
the format. -
The %i in the unit file will be
replaced with the port number in our
example when we call the start
command.
In order to run the application.
sudo systemctl start libreoffice@8101.service
sudo systemctl start libreoffice@8102.service
sudo systemctl start libreoffice@8103.service