How can I run multiple instances of soffice under linux.

asked 2016-11-25 18:04:44 +0200

FluxV gravatar image

updated 2016-11-25 18:08:46 +0200

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
edit retag flag offensive close merge delete

Comments

Nice, Thanks :thumbsup:

mitchbw gravatar imagemitchbw ( 2018-06-14 14:01:10 +0200 )edit