【问题标题】:How could I disable some configs if I'm loading from IEx?如果我从 IEx 加载,如何禁用某些配置?
【发布时间】:2017-04-17 15:50:35
【问题描述】:

我有大量的quantum 作业在我的iex 中生成日志垃圾。来自我的phoenix 应用程序:

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

所以,我希望这部分只包含在来自 phoenix.server 的配置中,而不是来自 IEx。我怎么能这样做?

【问题讨论】:

  • 这对你有用吗:if IEx.started? do; config :quantum, MyApp, cron: [ # Tons of jobs here ]; end?
  • 是的,但是unless。请你把答案贴出来好吗?

标签: elixir phoenix-framework elixir-mix


【解决方案1】:

您可以使用IEx.started?/0 检查iex 是否正在运行。如果你把它放在unless 中并将config 调用包装在其中,那么只有在iex 没有运行时才会添加配置:

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

【讨论】:

  • 非常感谢,亲爱的 Dogbert!
猜你喜欢
  • 2013-06-05
  • 1970-01-01
  • 1970-01-01
  • 2017-10-12
  • 2014-08-09
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2016-08-03
相关资源
最近更新 更多