November, 2017
23
After a break in our “new languages” series, today we present Elixir. This functional language, created in 2011 and using the Erlang VM, is known among other things for its fault tolerance and hot swapping.
Fifth major language
Elixir is the fifth “major” language to be supported on alwaysdata. We recently explained in detail what constitutes a major language, so we won’t reiterate that here. We’ll just mention that we’re offering the latest version of Elixir (1.5.2), operating on Erlang 19.2, and that a new type of site has appeared in our administration panel.
Example: deploying a Phoenix application
Phoenix is one of the primary web frameworks for Elixir. Which is why it’s the one that we’ll be using in our deployment example.
Let’s log into our SSH account, then install Phoenix, and create a new application:
1 2 3 4 5 | $ mix local.hex $ mix local.rebar $ mix archive.install https://github.com/phoenixframework/archives/raw/master/phx_new.ez $ mix phx.new myapp --no-brunch --no-ecto $ cd myapp |
We need to edit the file config/prod.exs in such a way as to replace the line:
1 | load_from_system_env: true, |
with:
1 2 3 4 | http: [ ip: elem(:inet.parse_address(to_charlist(System.get_env("IP"))), 1), port: System.get_env("PORT") ], |
Finally, we have to compile the application:
1 2 | $ MIX_ENV=prod mix compile $ MIX_ENV=prod mix phx.digest |
Last step, let’s go into alwaysdata’s administration panel, then create an Elixir website and specify:
- command: mix phx.server
- working directory: myapp
- environment: MIX_ENV=prod
And there you have it, our application is reachable via the web and will show Welcome to Phoenix!
Next language to get its moment in the blog’s spotlight: Java.
no comments