Open WolfgangFahl opened 3 years ago
As a workaround i tried the script below which would help automating things a bit. Unfortunately the used shell exec is firejailed and won't allow the automatic download. So you have to run this script once manually from the shell and then it might work in the MediaWiki environment. try e.g.
plantuml -help
/usr/local/bin/plantuml This is a debug version it creates log output in /tmp/plantuml.log
#!/bin/bash
# WF 2020-10-22
# invoke plantuml
# plantuml version to use if not there yet
url=http://sourceforge.net/projects/plantuml/files/plantuml.1.2020.19.jar/download
# jar file to use
jarPath=/var/www/mediawiki/code/extensions/Diagrams
jar=$jarPath/plantuml.jar
tmp=/tmp/plantuml.log
# check if jar is available
if [ ! -f $jar ]
then
#if not download it
# allow writing of target path
chmod g+w $jarPath
echo "trying download of $jar " > $tmp
wget $url -O $jar 2>&1 >> $tmp
echo "$?" >> $tmp
fi
# pass on all arguments
echo /usr/bin/java -Djava.awt.headless=true -jar $jar "$@" >> $tmp
/usr/bin/java -Djava.awt.headless=true -jar $jar "$@"
Unfortunately I end up with "Diagrams error:" and no further output but i assume i am closer .. The command generated look like:
/usr/bin/java -Djava.awt.headless=true -jar /var/www/mediawiki/code/extensions/Diagrams/plantuml.jar -T png -o /tmp/diagrams_out_0d08672f3429.png /tmp/diagrams_infee4f7bba8d0
running from the command line gives "no diagram found" and i assume this is because of the intermediate files being removed if the command is not successful. Also the tmp jailing might be a problem here i am not sure whether the tmp files create by mediawiki are visible in the shell firejail environment by default.
Error occurred during initialization of VM
Could not reserve enough space for 256000KB object heap
was the error message - is that some shell restriction? It would be good if such error output would show somewhere e.g. in a debug log ...
the good old
$wgMaxShellMemory = 512000;
is need here again ...
https://serverfault.com/a/596765/162693?
ulimit -a
...
file size (blocks, -f) 102400
...
max locked memory (kbytes, -l) 64
max memory size (kbytes, -m) unlimited
...
virtual memory (kbytes, -v) 512000
A binary search has shown I need at least
ulimit -v 3750000
to succesfully run plantuml. When i set
$wgMaxShellMemory = 4*1024*1024;
I get Diagrams error: Warning: no image in /tmp/diagrams_in1a22ba96f9f6 No diagram found
The wrapping with @startuml/@enduml is missing ... is the plantuml script supposed to do this?
For reference i tried
sudo port install plantuml
on my mac and inspected the plantuml script there. It contains
#!/bin/sh
# Is the location of the PlantUML launcher JAR file.
LAUNCHJAR="/opt/local/share/java/plantuml.jar"
exec java -jar "$LAUNCHJAR" "$@"
which is a very short version of my own debugging script.
The current state of the debugging script is
#!/bin/bash
# WF 2020-10-22
# invoke plantuml
# plantuml version to use if not there yet
url=http://sourceforge.net/projects/plantuml/files/plantuml.1.2020.19.jar/download
# jar file to use
jarPath=/var/www/mediawiki/code/extensions/Diagrams
jar=$jarPath/plantuml.jar
# create a log file
log=/tmp/plantuml.log
debug=true
clearlog() {
if [ -f $log ]
then
rm $log
fi
}
#
# log the given message
# param 1: msg - the message to log
#
dolog() {
local l_msg="$1"
echo "$l_msg" >> $log
}
# remove existing log if any
clearlog
# check if jar is available
if [ ! -f $jar ]
then
#if not download it
# allow writing of target path
chmod g+w $jarPath
dolog "trying download of $jar "
wget $url -O $jar 2>&1 >> $log
dolog "wget return-code: $?"
fi
# pass on all arguments
dolog "ulimit -a"
ulimit -a >> $log
dolog "/usr/bin/java -Djava.awt.headless=true -jar $jar $@"
for var in "$@"
do
dolog "param: $var"
if [ -f $var ]
then
dolog "ls -l $var"
ls -l $var >> $log
cat $var >> $log
b=$(basename $var)
# create a copy for inspection
cp -p $var /tmp/$b.bak
fi
done
# log run
/usr/bin/java -Djava.awt.headless=true -jar $jar "$@" >> $log 2>&1
# true run
/usr/bin/java -Djava.awt.headless=true -jar $jar "$@"
Which creates .bak copies of the input and shows that the plantuml process is called three times on each edit!
the path to plantuml.jar used to be configurable in https://www.mediawiki.org/wiki/Extension:PlantUML - unfortunately it's a somewhat undocumented feature there. https://github.com/pjkersten/PlantUML/blob/master/extension.json shows the config parameter. Is there something similar for the diagrams extension to avoid the error above and what is the expected setting to get a local plantuml running?