Elixir, Exrm and Conform

Hello,

I am trying to use Exrm and Conform with my Phoenix application.
The main goal for me is to be able to control the port that Phoenix/Cowboy would use for server.
I would like to be able to set PORT env variable while starting Phoenix so it would use this value.
I am talking here about released version. I made it to work with development version but as far as I know there are different rules for prod and dev versions.
I have created app.conf file and schema.exs. The task mix conform.effective shows that my changes in schema work but still it looks like the application does not take into account while being started.

Maybe there is something that I am missing from https://exrm.readme.io/docs/release-configuration.
I have tried solution mentioned here http://carlo-colombo.github.io/2016/05/04/The-3-E-Elixir-Exrm-and-Environment-Variables/.

I tried to ask this question on Slack but got no answer.

Anyone succeeded maybe with such solution?

Regards

1 Like

Perhaps I should use this as well https://github.com/bitwalker/conform_exrm ?

1 Like

I have copied app.conf and app.schema.exs into /app/rel/app/releases/0.0.1 and tried to run app.sh console

It complained about missing conform file in the/rel/app/bin dir.
I have cloned conform repo and copied conform there and now it seems to work as I wanted.
I can use now PORT=1212 app console and server is started on this port 1212.
This however looks like a workaround not proper final solution.

Anyone has maybe instruction for conform? Do I have to use Distillery as well?

1 Like

Which version of elixir are you using and how have you added :conform to your dependencies and app fields?

1 Like

I am using Elixir 1.3.3

I have added that into application:
def application do applications: [:phoenix,...., :conform] end

and in the
defp deps do [{:conform, "~>2.1"}] end

1 Like

On a first glance this looks correct, so conform should be included in your release…

1 Like

Trying to find out more. I have checked what is in the tar file produced from mix release.
In the bin dir there is a conform present but app.conf and app.schema.exs are not.
I have unpacked tar file and then copied those two files in to /releases/0.0.1 and now this works as well.

Why those two files were not packed into tar file? Where should I have them? After using mix conform.new and .configure I have them in the config dir in my Phoenix app.

1 Like

Is there a reason you are using exrm and not distillery? If there isn’t, you should use the latter, as I’m no longer actively maintaining exrm, and any release-specific assumptions conform makes in the future will be based on distillery’s behaviour.

If you are using exrm for a specific reason, you’ll need to use conform_exrm, and to use a release prior to 2.1 of conform, as later versions target distillery.

To answer your questions above, you need conform_exrm in order for the conform bits to be packed into the release. Without that plugin, they are completely independent libraries.

1 Like

I am using Exrm since I am still semi advanced with Elixir and Exrm was mentioned on Phoenix website as the tool for the release. Phoenix was my first Elixir application so I started with it and exrm.

Distillery is described as still in beta, it that correct?

1 Like

Distillery is now post-1.0, so it’s considered stable. The Phoenix docs need to be updated to mention that exrm is deprecated. Distillery now has a walkthrough guide for Phoenix anyway, so I think much of the Phoenix docs specific to exrm could be removed and just link to the Distillery guides, but that’s a choice Chris and the Phoenix core team will have to make.

In any case, please use Distillery going forward :slight_smile:

1 Like

But for runtime configuration I shall still use conform, am I right?

1 Like

Ooo, windows support finally? :slight_smile:

That is the only reason I’m still using exrm, I have distillery half-put in this system but it kind of did not work last I tried. ^.^

1 Like

It seems I am running into the same problems I had before. Now with Distillery and Conform.
I have new schema.exs and new conf file but those are again not included in the releases tar file.
I tried the same approach and copied them but this doesn’t seem to work.

1 Like

Did you read the documentation on how to use conform with distillery? You need to add the plugin in your rel/config.exs.

1 Like

In progress, but not ready for primetime yet. Hopefully sometime in March!

2 Likes

Quite possible I missed that. Thanks for pointing it out for me.

But I read Runtime Configuration chapter and started to think if I really need Conform now, perhaps I could use your config.ex module, or am I mixing things right now?

Thanks.

1 Like

Perhaps you could explain why you think you’ll need Conform, and I can tell you whether you really need it, or whether one of the simpler config mechanisms will suffice.

Regardless, if you would like to use Conform, the documentation for how to integrate it with Distillery is in the README on GitHub (which should also be the main documentation page on hexdocs.pm)

1 Like

I missed that part about Conform and Distillery but now I have added this one line into config file and it seems to work the way I wanted.

I need to control the port that Phoenix uses to start server on.
By default I would like to use 0 and let Phoenix (or rather Cowboy and Erlang gen_tcp) to choose free port for me.
In some cases however I would like to use predefined port number, so I would like to pass this value to Phoenix.
For this I would like to use system env variable MY_PORT (or something similar).

Thanks.

Even though Exrm is now considered as deprecated I liked it and now I think I will like Distillery :slight_smile:

1 Like