I'm trying to configure a ktor application using t...
# ktor
s
I'm trying to configure a ktor application using the configuration file, as described here: https://ktor.io/docs/configurations.html#configuration-file ... I've put a file on my
src/main/resources/application.conf
and works great. However, to deploy the app I create a fat jar. Is there a way to override some configuration options when I deploy that fat jar ? I know that I can use env vars but there are too many options that would need overriding. is it possible to pass another configuration file to the fatjar that would be used to override configuration options ? i.e run it like
java -jar ktor-fat.jar -c local.conf
; when trying to read a configuration value, it will first check
local.conf
, if not found then go to
resources/application.conf
inside the jar
a
Perhaps someone can correct me, but to get the most control over your server, you should start an embedded server and configure it like this. With this method, you can define your own config file format, parse it, and override whatever defaults you would pass into the server.
s
@Andrew O'Hara yes you've got a point on that, thank you
i'll refactor my app to use embedded server
any idea about a good configuration framework (that supports my initial requirement about overriding conf by an extra file) ?
a
Perhaps hoplite for your choice of config file format. Otherwise http4k-cloudnative for environment or .properties. That being said, it's pretty trivial to write your own code to deserialize some json into a data class, or read a .properties file.
s
Thank you Andrew, yes you're right I had written such code in the past. I'll check out your recommendations and if I don't like then I'll use a good old java. properties file :)
👍 1
l
Not sure if what you want might be similar to this question: https://kotlinlang.slack.com/archives/C0A974TJ9/p1667830944600919
1019 Views