Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Troubles getting started #155

Open
brandonparsons opened this issue Jun 16, 2018 · 6 comments
Open

Troubles getting started #155

brandonparsons opened this issue Jun 16, 2018 · 6 comments

Comments

@brandonparsons
Copy link

Hi there,

I'm trying to get started for the first time with conform. Having some trouble with what I thought would be the easy part! :)

I have an umbrella app - one of the applications inside houses an ecto repo. I decided to try to start pulling in conform in that app as it would be easiest to know if something was broken.

I've created shared_repo.schema.exs and shared_repo.dev.conf. If I use mix conform.effective, I see some values I expect:

shared_repo: [
    {SharedRepo.Repo,
     [
       adapter: Ecto.Adapters.Postgres,
       database: "myapp_dev",
       hostname: "localhost",
       loggers: [
         {Ecto.LogEntry,
          :log,
          []}
       ],
       pool_size: 10
     ]},
    {:ecto_repos,
     [SharedRepo.Repo]}
  ]

However, when I attempt to boot the app, it blows up as it can't find a database key inside the configuration for the repo. I'm a bit confused and don't know what to do next. The app boots fine just using a standard config.exs and config.dev.exs.

Any help you could provide would be appreciated!

@happysalada
Copy link

Actually, it's funny, I'm running into a similar problem.
Here is the additional check I performed.

  • If you are making a release, verify that in the rel/config.exs you have added the plugin(Conform.ReleasePlugin)

It's funny as well, if I leave my prod.ex file the way it was before using conform so with a line like

config :union, Union.Repo,
  adapter: Ecto.Adapters.Postgres,
  url: System.get_env("DATABASE_URL"),

Then I find that when I deploy my release the "DATABASE_URL" gets read from the system just when I start the app with the bin script start. So that if I have that env var set when I start it works, if I don't have it, it doesn't work. I always heard that the system.get_env gets read at compile time, it is not true in my case.

If I remove the url line from my prod.ex entirely, then on start I have a database_url not find.

I verified on both cases that the sys.config file gets generated properly with all the values I want.

Did I forget anything, what am I doing wrong?

@happysalada
Copy link

Ok After some more research on this
looking into my release directory, there is a sys.config file that has the missing env variables
/test/union/releases/0.0.23+7cce925-staging/sys.config
But when I start my app it says that the following config file was generated
/test/union/var/sys.config and this one is correct.
How do I tell the start script to use that sys.config file instead of the other ?

@brandonparsons
Copy link
Author

@happysalada Did you manage to figure anything out on this? I'm still stuck...

@happysalada
Copy link

@brandonparsons so in the distillery library it talks about several environment variables that you can configure (stuff like RELEASE_CONFIG_DIR, find some more here). I tried changing some of them but couldn't get it to work. Maybe you'll be luckier.

What I ended up doing was using the REPLACE_OS_VARS=true trick. You set that env variable and then in your config file you replace System.get_env by "${your_env_variable}". That worked for me.

@brandonparsons
Copy link
Author

brandonparsons commented Jun 25, 2018 via email

@Fire-Dragon-DoL
Copy link

Hello. Facing a similar problem.
I got everything "working" from the conform side, in the sense that I was able to produce a sys.config file for my dev environment which is loaded using: iex --erl "-config $PWD/sys.config" -S mix phx.server (I know it's correctly loaded because if I enter gibberish, the app doesn't start).
But then everything in there gets ignored.

Is there any way to use sys.config in dev mode? It's quite important both for practicing and to allow devs to have their own config (for example: change port)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants