Deploying an Elixir application with edeliver: Troubleshooting

Deploying elixir applications using Edeliver - Coletiv Blog

I successfully deployed an Elixir application to an Amazon EC2 and decided to compile a list of the issues and solutions that I’ve encountered and found little or no information regarding it.

After researching for a few days and asking around in the community I came to the conclusion that in our specific case the best tool to deploy an Elixir application is edeliver. It uses distillery (or exrm) to create a single package with all the code needed to be deployed on a server.

There are still available other ways of deploying an Elixir application to AWS using CodeDeploy, Elastic Beanstalk, Kubernetes and so on. In some of them you lose some functionality of Elixir (Erlang) like hot swap and communication between nodes, but at the moment the simplicity of edeliver is more than enough for my needs.

Confusing information on README.md

I followed the README.md file and it assumes by default that the distillery module is used. That was what I was thinking in using too, but after trying to deploy the application, I got the following message: cat: deps/exrm/mix.exs: No such file or directory.

In the readme file after the quick start section, you can check that you have this environment variable you can setup to use distillery, which means that setting USING_DISTILLERY=true solves the issue.

Phoenix deployed but no listening port open

After successfully deploying the service, I couldn’t reach it because the default port wasn’t available (used netstat -tulpn to check).

If you are deploying a Phoenix application be aware that on prod.exs file you need to uncomment config :phoenix, :serve_endpoints, true for the server start to accept requests.

Also if you don’t setup a fixed port, be sure you set an environment variable PORT with the port you want your web server to be listening, export PORT=80 on the server side, or check RELX_REPLACE_OS_VARS=true to include this information on the deploy.

Missing Modules

If your application is saying that modules are missing, run command mix release to check what modules is missing on your mix.exs file.

Some Elixir modules don’t state in their README.md that you need to explicit include the module on the applications entry and the problem is that on development mode (using mix phx.server) the application doesn’t show any issue with it.

def application do
    [mod: {MyApp, []},
    applications: [
        :canary,
        :corsica,
        ...
        :edeliver
    ]]
end

Conclusion

I’m still giving my first baby steps towards the Elixir/Erlang work, but I will try to keep this article up to date if I encounter some more issues with it.

Thank you for reading!

Thank you so much for reading, it means a lot to us! Also don’t forget to follow Coletiv on Twitter and LinkedIn as we keep posting more and more interesting articles on multiple technologies.

In case you don’t know, Coletiv is a software development studio from Porto specialised in Elixir, iOS, and Android app development. But we do all kinds of stuff. We take care of UX/UI design, web development, and even security for you.

So, let’s craft something together?