how to get plantuml server on heroku to respect GRAPHVIZ_DOT ​

0 votes
asked Nov 20, 2018 in Question / help by tcab (200 points)

I managed to deploy the plantuml server to heroku by git clone https://github.com/plantuml/plantuml-server.git and creating a Procfile containing

web: java $JAVA_OPTS -jar target/dependency/jetty-runner.jar --port $PORT target/*.war 

​git push heroku master

worked and produces sequence diagrams, but for class diagrams, cannot find the Dot executable even though I added a buildpack with dot and set the appropriate environment variable thus:

heroku buildpacks:add --index 2 https://github.com/weibeld/heroku-buildpack-graphviz.git

heroku config:set GRAPHVIZ_DOT=/app/heroku-buildpack-graphviz/usr/bin/dot

The planuml server keeps looking in /opt/local/bin/dot rather than respecting my GRAPHVIZ_DOT environment variable.  Why?  Interestingly, running 

heroku run java -jar ./target/plantuml/WEB-INF/lib/plantuml-1.2018.12.jar -testdot

​does indeed report the correct path to dot.  Perhaps the jetty-runner is not picking up heroku environment variables?  I don't know anything about java servers and am amazed I got this far!  Any help on this final step would be appreciated! 

1 Answer

0 votes
answered Nov 20, 2018 by plantuml (295,000 points)

Not sure about jetty-runner...

Maybe you can create a symbolic link from /opt/local/bin/dot to /app/heroku-buildpack-graphviz/usr/bin/dot (ok, not very clean). At least it should work.

The plantuml server keeps looking in /opt/local/bin/dot rather than respecting my GRAPHVIZ_DOT environment variable.  Why?  

Maybe the GRAPHVIZ_DOT environment variable is not exported ? Is there another way for you to test it ?

 

commented Nov 20, 2018 by tcab (200 points)
> Not sure about jetty-runner...

jetty-runner is the runner used in the pom.xml supplied in the plantuml server git repo and responsible for successfully running plantuml server locally. Heroku instructions talk about webapp-runner not jetty-runner, but I'm not sure of the difference - can we change to webapp-runner?  Actually Heroku does talk about jetty-runner but I don't quite understand what they are saying https://devcenter.heroku.com/articles/java-webapp-runner

> Maybe you can create a symbolic link

I tried

heroku run mkdir -p /opt/local/bin && ln /opt/local/bin/dot /app/heroku-buildpack-graphviz/usr/bin/dot

but got the error
mkdir: cannot create directory '/opt': Read-only file system
ln: failed to access '/opt/local/bin/dot': No such file or directory

drats.  Could have been a quick hack.

> Maybe the GRAPHVIZ_DOT environment variable is not exported ?

Yes that's what I think is happening.  It is exported (as I mention in my OP) when running via  java -jar ... but not when part of the jetty-runner.  I'm a Python developer and out of my depth debugging this.

I would be great to be able to deploy plantuml to heroku and dokku, though - wouldn't it ;-)  I feel like we are mere inches away...
commented Nov 20, 2018 by plantuml (295,000 points)
You have also the option to modify your "Procfile" in:

web: java -DGRAPHVIZ_DOT=/app/heroku-buildpack-graphviz/usr/bin/dot $JAVA_OPTS -jar target/dependency/jetty-runner.jar --port $PORT target/*.war
commented Nov 21, 2018 by tcab (200 points)
Thanks for that suggestion - tried that and still got the error.  But then I noticed that other diagrams were working. Intriguing.

So I reverted the Procfile to what it was and other diagrams were still working.  So my original setting of the heroku environment variable for GRAPHVIZ_DOT was indeed working.  So why was I still getting an error image about not finding the dot executable for my test plantuml text?

Turns out it is a caching issue. Once you get a server error for a particular diagram, and submit the same plantuml text, the same long url is generated by the local client browser plantuml javascript encoder and the browser repeatedly returns the old error image result from local cache.  I was using chromium on linux.

By holding the SHIFT key and refreshing the page, re-rendering occurred and I got the correct result!
...