Search code examples
elixirphoenix-frameworkelixir-mix

How could I disable some configs if I'm loading from IEx?


I have tons of quantum jobs that generates log trash inside my iex. From my phoenix app:

# config/dev.exs
config :quantum, MyApp,
  cron: [
    # Tons of jobs here
  ]

So, I want this part to be included in configs only from the phoenix.server, but not from IEx. How could I do that?


Solution

  • You can check if iex is running using IEx.started?/0. If you put this in unless and wrap the config call inside it, the config will only be added if iex is not running:

    # config/dev.exs
    unless IEx.started? do
      config :quantum, MyApp,
        cron: [
          # Tons of jobs here
        ]
    end