I have the problem, that e.g. creating an invoice from an odt needs around 4-5 seconds, which is kinda long if a user sits and waits till its done, especially if user has to do 50 invoices.
Creating the invoice with the included php version is fast as it should be.
Server has 32 GB RAM and enough CPU. Top shows soffice is loaded, short goes on 60-100% then its done. But all together needs 4-5 secs and users complain.
Running a VM on Proxmox Cluster using CEPH Storage. Things are pretty fast normally.
Any hints where to look at?
which invoice numbering and template are you using?
Using terre, but it looks like i found the problem in startup time of soffice. I created a systemd script now to run soffice as daemon and give unoconv a try. need to recreate the debian package, because on bookworm it still wants python 3.11
1 Like
Please keep us posted about the progress.
I did figure it was startup time, though I would expect Linux to cache the files once they had been loaded from disk
SOLUTION to the slow convert:
[Unit]
Description=LibreOffice service
After=syslog.target
[Service]
ExecStart=soffice --nologo --headless --nofirststartwizard --accept='socket,host=127.0.0.1,port=2220,tcpNoDelay=1;urp;StarOffice.Service'
Restart=always
KillSignal=SIGQUIT
Type=simple
StandardError=syslog
User=www-data
#User=ctsroot
[Install]
WantedBy=multi-user.target
Change in includes/odtpdf.php
+++ odf.php 2025-10-01 21:55:45.052000000 +0200
@@ -844,7 +844,8 @@
// using linux/mac libreoffice that must be in path
// Note PHP Config "fastcgi.impersonate=0" must set to 0 - Default is 1
$command ='soffice --headless -env:UserInstallation=file:'.(getDolGlobalString('MAIN_ODT_ADD_SLASH_FOR_WINDOWS') ? '///' : '').'\''.$conf->user->dir_temp.'/odtaspdf\' --convert-to pdf --outdir '. escapeshellarg(dirname($name)). " ".escapeshellarg($name);
- } elseif (preg_match('/unoconv/', getDolGlobalString('MAIN_ODT_AS_PDF'))) {
+ //} elseif (preg_match('/unoconv/', getDolGlobalString('MAIN_ODT_AS_PDF'))) {
+ } elseif (getDolGlobalString('MAIN_ODT_AS_PDF') == 'unoconv') {
// If issue with unoconv, see https://github.com/dagwieers/unoconv/issues/87
// MAIN_ODT_AS_PDF should be "sudo -u unoconv /usr/bin/unoconv" and userunoconv must have sudo to be root by adding file /etc/sudoers.d/unoconv with content www-data ALL=(unoconv) NOPASSWD: /usr/bin/unoconv .
@@ -869,8 +870,9 @@
// - set shell of user to bash instead of nologin.
// - set permission to read/write to user on home directory /var/www so user can create the libreoffice , dconf and .cache dir and files then set permission back
- $command = getDolGlobalString('MAIN_ODT_AS_PDF').' '.escapeshellcmd($name);
+ //$command = getDolGlobalString('MAIN_ODT_AS_PDF').' '.escapeshellcmd($name);
//$command = '/usr/bin/unoconv -vvv '.escapeshellcmd($name);
+ $command = '/usr/bin/unoconv -vvvv -n --connection "socket,host=127.0.0.1,port=2220,tcpNoDelay=1;urp;StarOffice.ComponentContext" '.escapeshellcmd($name);
} else {
// deprecated old method using odt2pdf.sh (native, jodconverter, ...)
$tmpname=preg_replace('/\.odt/i', '', $name);
Now ODT2PDF is more or less same speed as pdf template.
NOTE: The /var/www homedir of the www-data user must be chowned to www-data so the .config and .cache dirs can be created.
1 Like