Canton startup script

Hello,

I need to set up a custom Logback appender to ship my logs towards tools like Loki. To do that i’m using a custom Logback configuration file as suggested here.

Next step is to put the custom appender JAR on my classpath, and this is where i’m facing issues. Namely the bash script starting canton (canton/bin/canton) uses
java -jar canton.jar
so it’s not picking up --classpath/-cp options.

Is there another way to achieve that? Or if not, wouldn’t it be a good idea to change this script, so it uses
-cp $CLASSPATH:${PROG_HOME}/lib/canton.jar MainClass?
or another dedicated option? I’ve been able to achieve what i need with the above, but it’s obviously not a good solution as i need to mess around with canton files shipped with the whole package.

Thanks in advance!

Hi @Piotr_Ostrowski , welcome to the Daml forums. You can set JVM options including classpath either through the JAVA_OPTS environment variable or the -D command line flag. See documentation here.

Hi @bernhard,

I’m aware of JAVA_OPTS env variable, but just as i described in my initial question - all of the classpath settings are ignored by java when you use -jar option. The JAR you’re specifying is supposed to be the the source of all of your classes. (Please refer to this documentation, -jar option description in particular).

Having all that in mind i changed the /canton/bin/canton script to use another way of running a JAR, that is actually able to pickup classpath settings. To make this possible, instead of using:
java -jar canton.jar
one should be using:
java -cp canton.jar MainClass
MainClass is obviously the one you’ll find in the canton.jar manifest. (e.g. com.digitalasset.canton.CantonEnterpriseApp for your canton-enterprise).

So my question still stands, wouldn’t it be a good idea to modify the startup script? Or is there something else that i’m missing? If so, please elaborate.

Thanks for your help!

It does make sense to change this! The launch script is actually taken from sbt-pack and has been adapted for our purpose (as the company policy is to ship fat jars). The template also uses -cp over jar, so it shouldn’t be hard to change this. I’ve added an internal (lower priority) issue to our internal issue tracking system.

2 Likes