Skip to content
Snippets Groups Projects
Unverified Commit 75e935d7 authored by Anton Georgiev's avatar Anton Georgiev Committed by GitHub
Browse files

Merge pull request #11809 from gustavotrott/develop

Enhancements to presentation OfficeToPDF conversion
parents 87b770fe b0cddb4b
No related branches found
No related tags found
No related merge requests found
Showing
with 82 additions and 85 deletions
......@@ -39,7 +39,7 @@ public abstract class Office2PdfPageConverter {
private static Logger log = LoggerFactory.getLogger(Office2PdfPageConverter.class);
public static boolean convert(File presentationFile, File output, int page, UploadedPresentation pres,
String presOfficeConversionExec){
String presOfficeConversionExec, int conversionTimeout) {
try {
Map<String, Object> logData = new HashMap<>();
......@@ -61,11 +61,12 @@ public abstract class Office2PdfPageConverter {
NuProcessBuilder officeConverterExec = new NuProcessBuilder(Arrays.asList(presOfficeConversionExec, presentationFile.getAbsolutePath(), output.getAbsolutePath()));
Office2PdfConverterHandler office2PdfConverterHandler = new Office2PdfConverterHandler();
officeConverterExec.setProcessListener(office2PdfConverterHandler);
NuProcess process = officeConverterExec.start();
try {
process.waitFor(0, TimeUnit.SECONDS);
process.waitFor(conversionTimeout, TimeUnit.SECONDS);
} catch (InterruptedException e) {
log.error("InterruptedException while counting PDF pages {}", presentationFile.getName(), e);
}
......@@ -104,4 +105,6 @@ public abstract class Office2PdfPageConverter {
}
}
}
......@@ -28,12 +28,16 @@ import org.slf4j.LoggerFactory;
import java.io.File;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.Semaphore;
public class OfficeToPdfConversionService {
private static Logger log = LoggerFactory.getLogger(OfficeToPdfConversionService.class);
private OfficeDocumentValidator2 officeDocumentValidator;
private boolean skipOfficePrecheck = false;
private String presOfficeConversionExec = null;
private Semaphore presOfficeConversionSemaphore = new Semaphore(4);
private int presOfficeConversionTimeout = 60;
/*
* Convert the Office document to PDF. If successful, update
* UploadPresentation.uploadedFile with the new PDF out and
......@@ -93,12 +97,26 @@ public class OfficeToPdfConversionService {
presentationFile.getAbsolutePath().lastIndexOf('.'));
return new File(filenameWithoutExt + ".pdf");
}
private boolean convertOfficeDocToPdf(UploadedPresentation pres,
File pdfOutput) {
private boolean convertOfficeDocToPdf(UploadedPresentation pres, File pdfOutput) {
boolean success = false;
int attempts = 0;
while(!success) {
success = Office2PdfPageConverter.convert(pres.getUploadedFile(), pdfOutput, 0, pres, presOfficeConversionExec);
try {
if(presOfficeConversionSemaphore.availablePermits() == 0) {
log.info("Waiting for previous conversions finish before start (meetingId: {}, presId: {}, filename: {}), current queue: {}.",
pres.getMeetingId(), pres.getId(), pres.getName(), presOfficeConversionSemaphore.getQueueLength());
}
presOfficeConversionSemaphore.acquire();
success = Office2PdfPageConverter.convert(pres.getUploadedFile(), pdfOutput, 0, pres,
presOfficeConversionExec, presOfficeConversionTimeout);
} catch (Exception e) {
} finally {
presOfficeConversionSemaphore.release();
}
if(!success) {
if(++attempts != 3) {
......@@ -129,5 +147,13 @@ public class OfficeToPdfConversionService {
this.presOfficeConversionExec = presOfficeConversionExec;
}
public void setPresOfficeConversionTimeout(int presOfficeConversionTimeout) {
this.presOfficeConversionTimeout = presOfficeConversionTimeout;
}
public void setPresOfficeConversionMaxConcurrents(int presOfficeConversionMaxConcurrents) {
presOfficeConversionSemaphore = new Semaphore(presOfficeConversionMaxConcurrents);
}
}
FROM openjdk:8-jre
ENV DEBIAN_FRONTEND noninteractive
RUN apt update
RUN apt -y install locales-all fontconfig libxt6 libxrender1
RUN apt -y install --no-install-recommends libreoffice fonts-crosextra-carlito fonts-crosextra-caladea fonts-noto fonts-noto-cjk
RUN dpkg-reconfigure fontconfig && fc-cache -f -s -v
VOLUME ["/usr/share/fonts/"]
ADD ./bbb-libreoffice-entrypoint.sh /usr/local/bin/
ENTRYPOINT ["/usr/local/bin/bbb-libreoffice-entrypoint.sh" ]
#!/bin/bash
## Initialize environment
/usr/lib/libreoffice/program/soffice.bin -env:UserInstallation="file:///tmp/"
## Run daemon
/usr/lib/libreoffice/program/soffice.bin --accept="socket,host=0.0.0.0,port=8000,tcpNoDelay=1;urp;StarOffice.ServiceManager" --headless --invisible --nocrashreport --nodefault --nofirststartwizard --nolockcheck --nologo --norestore -env:UserInstallation="file:///tmp/"
......@@ -4,6 +4,8 @@ if [ "$EUID" -ne 0 ]; then
exit 1;
fi;
cd "$(dirname "$0")"
DOCKER_CHECK=`docker --version &> /dev/null && echo 1 || echo 0`
if [ "$DOCKER_CHECK" = "0" ]; then
......@@ -21,9 +23,6 @@ else
echo "Docker already installed";
fi
#Uninstall old version of docker and service if exists (keep temporarily)
./uninstall-bbb-libreoffice.sh
IMAGE_CHECK=`docker image inspect bbb-soffice &> /dev/null && echo 1 || echo 0`
if [ "$IMAGE_CHECK" = "0" ]; then
echo "Docker image doesn't exists, building"
......@@ -36,11 +35,7 @@ FOLDER_CHECK=`[ -d /usr/share/bbb-libreoffice-conversion/ ] && echo 1 || echo 0`
if [ "$FOLDER_CHECK" = "0" ]; then
echo "Install folder doesn't exists, installing"
mkdir -m 755 /usr/share/bbb-libreoffice-conversion/
cp assets/convert-local.sh /usr/share/bbb-libreoffice-conversion/
cp assets/convert-remote.sh /usr/share/bbb-libreoffice-conversion/
ln -sfn /usr/share/bbb-libreoffice-conversion/convert-local.sh /usr/share/bbb-libreoffice-conversion/convert.sh
chmod 755 /usr/share/bbb-libreoffice-conversion/convert-local.sh
chmod 755 /usr/share/bbb-libreoffice-conversion/convert-remote.sh
cp assets/convert-local.sh /usr/share/bbb-libreoffice-conversion/convert.sh
chmod 755 /usr/share/bbb-libreoffice-conversion/convert.sh
chown -R root /usr/share/bbb-libreoffice-conversion/
else
......
#!/bin/bash
if [ "$EUID" -ne 0 ]; then
echo "Please run this script as root ( or with sudo )" ;
exit 1;
fi;
cd "$(dirname "$0")"
FOLDER_CHECK=`[ -d /usr/share/bbb-libreoffice-conversion/ ] && echo 1 || echo 0`
if [ "$FOLDER_CHECK" = "0" ]; then
echo "Install folder doesn't exists, installing"
mkdir -m 755 /usr/share/bbb-libreoffice-conversion/
cp assets/convert-remote.sh /usr/share/bbb-libreoffice-conversion/convert.sh
chmod 755 /usr/share/bbb-libreoffice-conversion/convert.sh
chown -R root /usr/share/bbb-libreoffice-conversion/
else
echo "Install folder already exists"
fi;
#!/bin/bash
set -e
if [ "$EUID" -ne 0 ]; then
echo "Please run this script as root ( or with sudo )" ;
exit 1;
fi;
IMAGE_CHECK=`docker image inspect bbb-libreoffice 2>&1 > /dev/null && echo 1 || echo 0`
if [ "$IMAGE_CHECK" = "1" ]; then
echo "Stopping services"
systemctl --no-pager --no-legend --value --state=running | grep bbb-libreoffice | awk -F '.service' '{print $1}' | xargs --no-run-if-empty -n 1 systemctl stop
echo "Removing image"
docker image rm bbb-libreoffice
fi
FOLDER_CHECK=`[ -d /usr/share/bbb-libreoffice/ ] && echo 1 || echo 0`
if [ "$FOLDER_CHECK" = "1" ]; then
echo "Stopping services"
systemctl --no-pager --no-legend --value --state=running | grep bbb-libreoffice | awk -F '.service' '{print $1}' | xargs --no-run-if-empty -n 1 systemctl stop
echo "Removing install folder"
rm -rf /usr/share/bbb-libreoffice/
echo "Removing service definitions"
rm /lib/systemd/system/bbb-libreoffice@.service
find /etc/systemd/ | grep bbb-libreoffice | xargs --no-run-if-empty -n 1 -I __ rm __
systemctl daemon-reload
fi;
NETWORK_CHECK=`docker network inspect bbb-libreoffice &> /dev/null && echo 1 || echo 0`
if [ "$NETWORK_CHECK" = "1" ]; then
echo "Removing docker network"
docker network remove bbb-libreoffice
fi
......@@ -7,10 +7,6 @@ if [ "$EUID" -ne 0 ]; then
fi;
#Uninstall old version of docker and service if exists (keep temporarily)
./uninstall-bbb-libreoffice.sh
IMAGE_CHECK=`docker image inspect bbb-soffice 2>&1 > /dev/null && echo 1 || echo 0`
if [ "$IMAGE_CHECK" = "1" ]; then
echo "Removing image"
......@@ -28,11 +24,3 @@ if [ "$FILE_SUDOERS_CHECK" = "1" ]; then
echo "Removing Sudoers file"
rm /etc/sudoers.d/zzz-bbb-docker-libreoffice
fi;
NETWORK_CHECK=`docker network inspect bbb-libreoffice &> /dev/null && echo 1 || echo 0`
if [ "$NETWORK_CHECK" = "1" ]; then
echo "Removing docker network"
docker network remove bbb-libreoffice
fi
#!/bin/bash
set -e
if [ "$EUID" -ne 0 ]; then
echo "Please run this script as root ( or with sudo )" ;
exit 1;
fi;
FOLDER_CHECK=`[ -d /usr/share/bbb-libreoffice-conversion/ ] && echo 1 || echo 0`
if [ "$FOLDER_CHECK" = "1" ]; then
echo "Removing install folder"
rm -rf /usr/share/bbb-libreoffice-conversion/
fi;
......@@ -98,6 +98,16 @@ numConversionThreads=5
#------------------------------------
numFileProcessorThreads=2
#------------------------------------
# Timeout(secs) to wait for conversion script execution
#------------------------------------
officeToPdfConversionTimeout=60
#------------------------------------
# Max concurrent of conversion script execution
#------------------------------------
officeToPdfMaxConcurrentConversions=4
#----------------------------------------------------
# Conversion of the presentation slides to SWF to be
# used in the Flash client
......
......@@ -38,6 +38,8 @@ with BigBlueButton; if not, see <http://www.gnu.org/licenses/>.
<property name="officeDocumentValidator" ref="officeDocumentValidator"/>
<property name="skipOfficePrecheck" value="${skipOfficePrecheck}"/>
<property name="presOfficeConversionExec" value="${presOfficeConversionExec:/usr/share/bbb-libreoffice-conversion/convert.sh}"/>
<property name="presOfficeConversionTimeout" value="${officeToPdfConversionTimeout}"/>
<property name="presOfficeConversionMaxConcurrents" value="${officeToPdfMaxConcurrentConversions}"/>
</bean>
<bean id="pageExtractor" class="org.bigbluebutton.presentation.imp.PageExtractorImp"/>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment