Proxy Information
Original URL
gemini://alltext.umaneti.net/gemlog/LibreOffice-Headless-with-systemd/index.gmi
Status Code
Success (20)
Meta
text/gemini # LibreOffice Headless with systemd I've fought a very annoying bug recently and think it's worth sharing it here. At work we manage different type of user provided documents. For various reason we convert it to pdf. This step is achieved using a headless libreoffice[1] installation. Our server run Debian GNU/Linux Wheezy[2] and everything go smoothly. Untilโ€ฆ one of our client need our software to be hosted on his own servers, running CentOS. Nothing bad here, but it leads us to develop various systemd service files for our systems as recent versions of CentOS switched to systemd. Here come the bug. We were used to run libreoffice as follow, embed in an init.d script: ```bash soffice -headless -accept="socket,host=127.0.0.1,port=8101;urp;" -display :5.0 -nofirststartwizard & > /var/log/soffice.log 2>&1 ``` Moving on systemd and more recent version of libreoffice, I learn that single-dotted options are no more. Thus, my first attempt to write a systemd service file, directly inspired by the line above, was: ```conf [Unit] Description=Control headless soffice instance After=network.target xvfb.service Requires=xvfb.service [Service] Type=simple ExecStart=/opt/libreoffice4.4/program/soffice --headless \ --accept="socket,host=127.0.0.1,port=8101;urp;" --display :5.0 \ --pidfile=/var/run/soffice.pid --nologo --nodefault --nofirststartwizard RestartSec=5 ExecStop=/usr/bin/pkill -F /var/run/soffice.pid PIDFile=/var/run/soffice.pid [Install] WantedBy=multi-user.target ``` And nothing works as expected. In fact, I'm lying a bit: the daemon was here, systemctl telling me everything is ok and libreoffice showing off in `ps axf'. But no conversion succeeded. The problem was obvious: looking at `netstat -laputn' show me that nothing was listening at port 8101. After weeks of test, we abandoned the problem (I just start the exactly same command by hand and forget it). Yesterday it comes to my face, due to a libreoffice crash, which prevents conversion to occurs. We use monit[3] to monitor our process, but in this case soffice wasn't monitored, as I didn't reached to have a functional service. As I was crying blood, because of not understanding the problem source, I try a last thing before fucking all of it and writing a quick'n'dirty shell script. And it works. ```conf [Unit] Description=Control headless soffice instance After=network.target xvfb.service Requires=xvfb.service [Service] Type=simple ExecStart=/opt/libreoffice4.4/program/soffice --headless \ --accept=socket,host=127.0.0.1,port=8101;urp; --display :5.0 \ --pidfile=/var/run/soffice.pid --nologo --nodefault --nofirststartwizard RestartSec=5 ExecStop=/usr/bin/pkill -F /var/run/soffice.pid PIDFile=/var/run/soffice.pid [Install] WantedBy=multi-user.target ``` Yes: nothing changes, but the quotation marks on line 9. The solution was simply to remove them from the `ExecStart' line. I absolutely don't know why putting here double quotes prevent systemd-started soffice to open a socket, but it does. If anyone has an explanation, I'm very curious. The documentation[4] itself is not very clear about that. Anyway, now we have a working service file for headless execution of libreoffice. => https://help.libreoffice.org/Common/Starting_the_Software_With_Parameters [1] headless libreoffice (HTTPS) [en] => https://www.debian.org/releases/wheezy/ [2] Debian GNU/Linux Wheezy (HTTPS) [en] => https://www.mmonit.com/monit/ [3] monit (HTTPS) [en] => https://www.freedesktop.org/software/systemd/man/systemd.service.html [4] documentation (HTTPS) [en] ## Commentaires nil ### Comment from Dani -- ๐Ÿ“… mercredi 23 mars 2016 ร  17:01 ๐Ÿ“ ร‰tienne Pflieger with GNU/Emacs 29.4 (Org mode 9.7.11) => gemini://alltext.umaneti.net/gemlog/tags/bidouille.gmi ๐Ÿท๏ธ Bidouille => gemini://alltext.umaneti.net/gemlog/tags/libreoffice.gmi ๐Ÿท๏ธ libreoffice => gemini://alltext.umaneti.net/gemlog/tags/linux.gmi ๐Ÿท๏ธ Linux => gemini://alltext.umaneti.net/gemlog/tags/script.gmi ๐Ÿท๏ธ script => gemini://alltext.umaneti.net/gemlog/tags/systemd.gmi ๐Ÿท๏ธ systemd => gemini://alltext.umaneti.net/gemlog ๐Ÿ“œ Back to gemlog => gemini://alltext.umaneti.net ๐Ÿก Back to home => gemini://alltext.umaneti.net/fronde/README.gmi ๐Ÿš€ Propelled by fronde
Capsule Response Time
119.071638 milliseconds
Gemini-to-HTML Time
0.011567 milliseconds

This content has been proxied by September (3851b).