anuaralfetahe
Recently I found out that changes made to the config.exs file did not apply to the running app.
I had to recompile and restart the app with iex -S mix.
I always thought that .exs files were not being compiled and interpreted when used.
Why keep configurations in the .exs file and not in the .ex if both are compiled?
I have read about runtime and compile time configurations and System.get_env/2 seems to be the only option for updating the configurations without actualy recompiling the app. If I am keeping my configurations in plain elixir in the runtime.exs file do I always need to recompile when making conf changes?
I would be very happy to hear how other people manage their application configurations. Thanks ![]()
Trending in Questions
Hey guys,
I’ve got a huge CSV ( around 10 GB ) that needs to be processed hourly
Do you guys have any suggestions what is the best prac...
New
Hello!
Could someone please give me a help/sample code, how to delete a file from s3 using waffle/waffle_ecto from Phoenix app.
I creat...
New
I’m seeing that a list inside a Kino.DataTable will be interpreted as a charlist, even if the Kino.configure() is set to charlists: :as_l...
New
So my question is quite simple and i have found no conclusive answer on forum, google or AI.
Should we use :erlang.float for Integer to ...
New
Hi, I’ve just set up an application with ash_authentication. There is only magic link strategy for now, so there is no confirmation add o...
New
If a change or preparation module uses Ash.Changeset.get_argument/2 or Ash.Query.get_argument/2 (or any of the other get_argument functio...
New
I’m trying to set up Emacs with elixir-ls via lsp-mode and credo via Flycheck. This should mostly be preconfigured as Flycheck picks up c...
New
Other Trending Topics
I am happy to introduce the very α version of the new programming language compiled to BEAM.
Welcome Cure.
It has literally three kille...
New
Hobbes is a low-level distributed database for the Elixir programming language.
Hobbes provides a simple, safe, and scalable storage lay...
New
Hi there! We created Gust: A task orchestrator inspired by Airflow.
For those who have never heard about Aiflow, it’s a Python-based wor...
New
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
ExRatatui lets you cook up rich terminal UIs in Elixir, powered by Rust’s ratatui via Rustler NIFs. Build interactive terminal applicatio...
New
Hello everyone. After busy few months I am happy to announce v0.1.0 of Emerge & Solve.
They are GUI (Emerge) and State management (S...
New
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #elixirconf
- #channels
- #exunit
- #discussion
- #code-sync
- #podcasts
- #javascript
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #blog-post
- #elixirconf-us
- #elixir-ls
- #ai
- #phoenix_html
- #iex
- #graphql
- #genstage
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #hex
- #security
- #metaprogramming










Showing Posts 1 to 10- Show Best Posts
- Show All (oldest first)
- Show All (newest first)
derek-zhou
Elixir is a compiled language. The only difference between .ex and .exs is the .ex file is compiled and written out as a binary file on the disk, but the .exs is compiled on the fly into memory and not serialized out.
The typical usage of
runtime.exsis to read values from environment variables then config the application at runtime. So you don’t change runtime.exs, only the startup script that set those environment variables.In most web applications, the majority of the configurations are admin changeable from the UI, and those are typically backed by the database. The amount of flat file configuration is kept low. We don;t want to restart the application too often, right?
anuaralfetahe
Thank you for your response!
I’ve been thinking about this and my application may have an architectural flaw and I should reduce the settings in the file.
The configurations are complex and consist of a linked lists and maps.
I have come up with a few ideas myself to update the configuration without restarting the app but I am not sure they would work as expected.
derek-zhou
Without knowing what do you want to achieve, I cannot make any suggestion. Neither of your ideas sound particularly attractive to me, to be honest.
anuaralfetahe
Thanks for the reply!
Well basically my application must hold many websocket connections.
Each websocket connection should have it’s own settings and I could disable/enable them ideally from the configurations.
Example settings are:
Configuration thru admin UI could be the resolution but I have no UI for the app yet.
I might have to update these values often.
IloSophiep
If you are in control of when the configuration changes, you could add an endpoint that “accepts and applies” config values you send in via HTTP?
No need for UI and all that work to get started. Just plain JSON (or whatever) in and you are good to go?
derek-zhou
I’d make a companion command-line tool that send/update the config in the server, through a UNIX domain socket. You can use a HTTP API as @IloSophiep suggested but then you’d need to worry about securing the HTTP endpoint with auth.
stefanchrobot
config/config.exsis read during build time andconfig/runtime.exsis read during application startup. Both of them are evaluated only once. To change the config of your app while it’s running, you need to do a bit of work yourself. I don’t think Elixir provides any tools for that out of the box.Nicd
You can use
Application.put_envto change configuration at runtime.Qqwy
Be aware however, that there are quite a number of tools which only look at the configuration when they themselves first start up (which is usually at elixir-application-startup time), after which changing the configuration settings using e.g.
Application.put_envmight have little effect.Check the particular tool(s) you are using to be sure if/when it reads the configuration.
(And generally speaking it is nice if tools are able to pick up new configuration at runtime, because it is not rare to want to alter how something behaves at runtime at all.)
anuaralfetahe
Thank you all for the answers.
Many good ideas heres.
For my use case unix domain socket seems the best solution, because I have ssh access to the server and this way I don’t need to open the port 80 and 443 to the outside world, so the application can make connections to the servers but not the other way around.