Elixir application with multiple / dynamic configuration files

I have an elixir application, an application server that will benefit from startup options. This application uses the ecto repository, so I can save the application server configuration there, but I still need a configuration key for what can be extracted from db.

I am currently using config.exs for a server application (the entire application is an umbrella project), but obviously this only handles one static configuration.

My question is: Can I use mix to indicate which configuration file I would like to use? I know that there are several functions in the Mix library, but from what I read, these are all the functions that you can use after starting the application. And similarly, is it possible to use mix to load configuration files for any of the child applications?

Thanks for the help provided.

EDIT: As requested ... After the main umbrella project has started (not knowing everything you need to know about umbrella projects, I assume that the order in which the child application starts does not matter, details for development later) the serverโ€™s child application using it launching arguments, queries the repository of child applications (Config.Query, contains queries that will be executed against the query table) for the complete application server configuration: listen on ipAddress and port, code directory, maximum number of connections, etc. This configuration is supported by genServer, which can be requested by other processes as needed.

defmodule Hermes.Server.Info do use GenServer def start_link() do GenServer.start_link(__MODULE__, :ok, [name: :hermes_server_configuration]) end def init(:ok) do system = Application.get_env(:hermes_server, :system, "dev") client = Application.get_env(:hermes_server, :client, "testClient") appServerName = Application.get_env(:hermes_server, :appServername, "testAppServerOne") config = Config.Query.get_config(system, client, appServerName) {:ok, config} end end 

So, if I could do something similar to elixir --detached -S mix run --config pathToConfigFile , even if it means creating my own bash script to get to the correct directory, this would be a better option, in my opinion . But after reading Patrickโ€™s answer, this is not possible; I didnโ€™t read that configuration files are something that was considered at compile time.

+3
source share
1 answer

Inline configuration is evaluated at compile time. To get the configuration at runtime, you need to use a third-party library such as conform or flip your own solution.

+4
source

All Articles