Hi, I have created 2 Hocon files. One for dev and ...
# ktor
v
Hi, I have created 2 Hocon files. One for dev and one for prod. When running the application, I am currently setting the dev config file like this
io.ktor.server.netty.EngineMain.main(arrayOf("-config=dev.conf"))
. Is it possible for the appropriate file to be set automatically based on my environment? How do I detect what environment I am in to be able to set the config file?
g
You can use environment variable to set required config
One more approach is to have specify special server runner for dev environment and specify different config
v
Thanks for your response Andrey, but using environment variables doesn’t allow me to change my config file. It only allows me to read the variables in the already loaded config file. Also what do you mean by specify a special server runner. Could you elaborate on how to do this?
g
You can change config file, because hocon files support environment variables, see doc which I sent above, you can just read env var if it available
About runner, I mean that depending how you start your server, you can just have 2 different tasks/commands to run it with different arguments
Also, after all, you free to load any config file manually, it's not necessary to use standard application.conf file, and use any loading logic as you want