Hiya, 2 beginner questions: 1. What’s the best way...
# ktor
d
Hiya, 2 beginner questions: 1. What’s the best way to run ktor server in production? I just need simple microservice running in docker in kubernetes. Do I just use embeddedServer() ? I don’t really know the difference between embedded vs non-embedded server, I missed whole “java ee embedded tomcat” thing and don’t know what “embedded” is supposed to mean. I am asking this question mainly because almost all ktor samples are starting engines directly without calling embeddedServer(). 2. I expected easy way of reading .conf files, I thought that they automagically would load up to some global config file, but it doesn’t seem to be the case. How was it intended to use and load .conf files?
d
1. Embedded just allows to setup a project programmatically. Non-embedded uses an application.conf in a way that you can reconfigure the application easily without recompiling. Other than that they are the same. 2. The idea is to have a single application.conf, that does the startup magic (loading the file, setting up the server with the right engine and the configured port, etc.). The rest of the things are magic-less.
d
thank you, follow up question: when I use embedded server and don’t set port, it defaults to 80 and doesn’t pick up the value from the config. Should I use commandLineEnvironment(args) for auto-magical set up?
it’s just feels weird to call something called “commandLine” to actually read from the file
👍 1
d
actually the commandline in addition to loading from the file, parses the args
d
Yeah, I mean i know it does it additionally, but the name is deceiving, it does a lot more than the name states
So i wasn't sure of its intended purpose
d
Yeah, agree. If you have a suggestion for a better name, I would open an issue/PR here: https://github.com/ktorio/ktor/issues
👍 1
m
FWIW, because I prefer to manage my own config, I have just a plain main method like any other Java program that does what I want to do with config and feeds the relevant bits of that to
embeddedServer()
.
This works fine in production (and allows me the flexibility to have config provided in different ways for local dev and prod, which is useful in my situation).