Category Archives: Elixir
As an exercise for catching up latest Phoenixframework features, I’ve updated an fairly old heroku app to the latest (v0.4.0 -> v1.1.1) version. It was harder than expected, and leaving some struggle notes here.
- Basically, the official document (http://www.phoenixframework.org/docs/heroku) covers the procedure to deploy phoenix application to heroku.
- Struggled on the error around missing
config/prod.secret.exswhich is described in the document.
- Also, there’re some configuration settings required around
config/prod.exsand it seems difficult to apply heroku button with fixed parameters.
- As phoenix requires node verison >= 5.0, and
phoenix_static_buildpack.configneeded to be specified by following the buildpack README description.
- Struggled on the error around missing
- The controller’s
json/2expects data model which
Poisoncan encode into JSON (changed from JSON data itself). I was using
exjsxand needed to change the data accordingly as keyword lists couldn’t be encoded.
- Reloading pages seems not working on Chrome + Ghostery, and just showing blank. It was confusing for isolating the issues.
- New asset compilation with
Brunchwas a difficult for me, as I don’t much experience on JS developments. The js files using global variables (highlight.js) needed to be stored in
vendordirectory instead of
jsas in the following document.
Anyway, re-realized upgrading from actively developed v0.x.y framework is very hard…
I once configured elixir build at CircleCI (Elixir on CircleCI), but haven’t been able to update it. As some of the builds are failing, I’ve updated the configurations as follows.
CircleCI doesn’t seem supports erlang/elixir builds, but there’s nice library (asdf) to configure specified versions of them. The 1st time build takes time, but caching works well and 2nd time or later becomes fast enough.
Just completed reading through the B2.0 of “Programming Phoenix” book during the weekend. I hadn’t been able to use phoenix some time since pre-1.0, but this book was a good material for catching up the latest features.
The book starts with the strong statements about the benefits of phoenix and underlying elixir, as in the subtitle – Productive |> Reliable |> Fast. Then, the main content explains the features by gradually building up simple and concise application called Rumbl. Building up standard CRUD operations to user models backed by Ecto with postgreSQL DB, and implementing authentication using the model didn’t take long and it was a good exercise.
Definitely looking for the remaining part to complete, which includes the web-socket channel.
I’ve started watching the session videos of elixir conf. I really wanted to join the conference if possible, but it’s good that I can watch every session online.
Recent history of extended elixir capability, and coming future enhancements.
The recently added mix profile.fprof provides nice and easy interface for profiling. The fprof of erlang is somewhat cryptic and difficult to start using. The new ex_doc styling is getting nicer, along some other improvements.
Also, the coming future features like pipeline parallelism and GenRouter will be more extending the capabilities in parallel and distributed system, which sounds promising.
It might be one of the best talk with insightful ideas and encouraging statements. It introduces the power of elixir by comparing with historical progress in physics. It’s an insightful talk about how progress is being introduced, and how it relates to computer and programming architecture. The history shows always new ideas are coming and we need to keep thinking about what’s coming next.
Elixir has strong powers of
- Functional Programming : Immutability with data flow through actors
- Object Oriented : Independency in processes and message communication between actors
- Errors : Isolation with crash and recovery mechanism
which is enforced by the related ideas and technologies coming in this age. One remaining part is the
People to spread the idea to the world, which elixir is improving at the moment. Elixir is providing different
paradigm and it imposes certain difficulty, and sharing various types of experiences at different levels helps new-comers to improve themselves.
I was trying to playing around Google’s BigQuery, but couldn’t make it work around OAuth 2.0 authentication with Elixir.
It provides limited functionalities yet, but the above oauth2ex provides some authentication features with some OAuth 2.0 providers like Google, GitHub and Dropbox.
Using OAuth 2.0 to Access Google APIs has detailed explanation, and it’s pretty much complex. There’re a lot too learn around authentication technologies.
Heroku recently announced “Deploy to Heroku” button. I just tried it out with spawn_viewer, which is a simple application built with elixir + phoenix. If you’ve already set-up heroku account, the following button would work.
Also, I’ve placed a link to the github readme too.
It’s pretty much an easy way to try out an application without messing up with local environment.
Just playing around docker and elixir. The followings are some notes about deploying sample phoenixframework application on docker.
- A container for elixir v0.14.2 on Ubuntu 14.04.
- A container for SpawnViewer sample application using phoenixframework.
- A chef cookbook to deploy docker-spawn-viewer container using chef-dooker.
Deploying using Vagrant is just adding the recipe to the chef.run_list.
config.vm.provision :chef_solo do |chef| ... chef.run_list = [ "recipe[docker]", "recipe[chef-docker-spawn-viewer]" ]
It’s just installing the erlang pack and then build elixir.
# Install base package RUN apt-get update RUN apt-get install -y wget git build-essential # Install Erlang RUN wget http://packages.erlang-solutions.com/erlang-solutions_1.0_all.deb RUN dpkg -i erlang-solutions_1.0_all.deb RUN apt-get update RUN apt-get install -y erlang # Install Elixir WORKDIR /tmp/elixir-build RUN git clone https://github.com/elixir-lang/elixir.git WORKDIR elixir RUN git checkout v0.14.2 && make && make install
It’s about fetching git repo and comple and start with “mix run” with “–no-halt” option. I’ve used phoenix-docker-example as reference.
## Prerequisites ## RUN mix do local.rebar, local.hex --force ## Fetch the phoenix application ## WORKDIR /usr/local/lib RUN git clone https://github.com/parroty/spawn_viewer.git ## Compile ## WORKDIR spawn_viewer RUN mix do deps.get, compile CMD ["mix", "run", "-e", "SpawnViewer.Router.start", "--no-deps-check", "--no-compile", "--no-halt"] EXPOSE 4000
chef-dooker makes it pretty easy to configure parameters for docker deployment.
# Pull latest image docker_image 'parroty/docker-spawn-viewer' # Run container exposing ports docker_container 'parroty/docker-spawn-viewer' do detach true port '4000:4000' end
Note: Related newer post is at Elixir on CircleCI – Updated
Just made small trial on CircleCI and elixir combination, and taking some notes here.
Though the CircleCI doesn’t have latest erlang/elixir installed, it can be installed as the custom configuration through circle.yml. It takes some time initially, but applying cache makes it pretty much fast for normal code deployments.
Comparing with TravisCI, detection of updates in GitHub and build processing seems pretty much fast, though there’s no free version on CircleCI. It may be a good option for private repositories.
The configuration is messy, but the following is the working example with very simple elixir codes (tested on erlang 17.0 and elixir v0.14.2-dev).
Playing around the process spawning of Erlang/Elixir. It’s an interesting framework, but I faced some difficulties to understand the concept initially. So, I was looking for a way to visually confirming the behavior and implemented a simple GUI. It’s preliminary yet, and might add more function later.
- It uses Google Chart to show timeline of process behaviors. For easier to make graph, delay is inserted in the spawn processing.
- It uses highlight.js to display Elixir codes.