Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Passing external configuration file? #11

Open
DarthJonathan opened this issue Mar 26, 2023 · 1 comment
Open

Passing external configuration file? #11

DarthJonathan opened this issue Mar 26, 2023 · 1 comment

Comments

@DarthJonathan
Copy link

DarthJonathan commented Mar 26, 2023

Hi @vmencik !

I have a question, how do we pass an external configuration file to the binary? I passed -Dconfig.file flag to the binary does not seem to work

./app -Dconfig.file=/opt/conf/application.conf

even when building I pass the config file.. for reference this is my build config

"-Dconfig.resource=/opt/conf/application.conf",
"--static",
"--verbose",
"--no-fallback",
"--install-exit-handlers",
"--enable-http",
"--enable-https",
"--enable-url-protocols=https,http",
"--allow-incomplete-classpath",
"--initialize-at-run-time=scala.util.Random$" +
",io.grpc.netty.shaded.io.netty.handler.ssl.ConscryptAlpnSslEngine" +
",io.netty.util.internal.logging.Log4JLogger" +
",io.grpc.netty.shaded.io.netty.internal.tcnative.CertificateCompressionAlgo",
"--initialize-at-build-time=io.netty.handler.ssl.BouncyCastleAlpnSslUtils" +
",ch.qos.logback",
"--report-unsupported-elements-at-runtime",
"-H:IncludeResources=.*\.properties",
"-H:+StaticExecutableWithDynamicLibC",
"-H:+RemoveSaturatedTypeFlows",
"-H:+ReportExceptionStackTraces",
"-H:-ThrowUnsafeOffsetErrors",
"-H:+PrintClassInitialization",
"-H:ReflectionConfigurationFiles=/build/graal/reflect-config.json",
"-H:Name=app",

thanks!

@vmencik
Copy link
Owner

vmencik commented Mar 29, 2023

Hi. It's been a while since I had my hands on this. In my notes I could only find one issue with the Lightbend Config library which was that it "caches" the environment in a static field, so I had to use this option to re-initialize it at runtime:

--rerun-class-initialization-at-runtime=com.typesafe.config.impl.ConfigImpl$EnvVariablesHolder,com.typesafe.config.impl.ConfigImpl$SystemPropertiesHolder

But this is only for the parts of the configuration that references environment variables or Java system properties.
I only used the application.conf files embedded as a classpath resource. I don't see why -Dconfig.file shouldn't work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants