3

I have an OTP Application (ChicagBoss actually). I'm trying to incorporate Phoenix app into it (as just casual OTP app).

I think that most of applications start, but I got error caused by lack of config file. How to provide configuration file to MIX application from outside? Especially in case when I try run it from rebar.How to provide the directory?

Saczew
  • 323
  • 2
  • 8
  • 2
    What does the error say? Which config file did it say was missing? Which application failed to start as a result? It's difficult to help without this kind of information. – Cody Poll Apr 28 '16 at 19:34
  • It was Repo application (related to Ecto I think). But I saw those conifg tuples in config file. I don't know how to let mix app know about config file. – Saczew Apr 28 '16 at 19:39

1 Answers1

2

When using Erlang project you shouldn't use mix configs, but erlang configs instead. In your particular example the boss.config file. In boss.config you have a list of tuples:

[{app, Options}, {second_app, Options}].

In Erlang shell you can check the config for given application with:

application:get_all_env(app).

In mix config files you have something like:

config :my_app, MyApp.Repo,
  adapter: Ecto.Adapters.Postgres

and you can check the config with:

Application.get_all_env(:my_app)

All you need to do is translate configs from Elixir to Erlang and put them inside boss.config. For example the Ecto adapter from above would become:

[...other apps...,
 {my_app, [{'Elixir.MyApp.Repo',
           [
            {adapter, 'Elixir.Ecto.Adapters.Postgres'}
           ]}]},
 ...other apps...
].

Just remember that foo: "bar" is a keyword list [{foo, <<"bar">>}] and module names in Elixir Foo are atoms in Erlang 'Elixir.Foo'.

Second option is to use Elixir umbrella project which pulls both Chicago Boss and Phoenix. In this case you would need to translate boss configs to Elixir.

tkowal
  • 9,129
  • 1
  • 27
  • 51