samvv

samvv

Transforming an Elixir Service Into a CLI Application

Hi all :smile:

I just wanted to provide you a quick tutorial related to a second tiny new library I’ve been developing. It’s called Takeoff, and you can find the source here.

A bit of background: I’ve been struggling with coming up with a good way to run Elixir services that are configured dynamically rather than statically, e.g. by using command-line arguments. One of the situations where I needed it was in my tests, when I wanted to spawn several instances of the same service on different ports.

I have in no way any idea if this is the Elixir way of doing things, but at least this library solves my use-case. There are four things you need to do to get it working:

  1. Add Takeoff as a dependency
  2. Remove applications that need to be configured dynamically from mix.exs
  3. Make sure your mix.exs can build an Escript version of your service.
  4. Add a tiny snippet of code describing the mapping between command-line arguments and configuration entries

The details are described here. It currently is just a quick proof-of-concept so don’t hesitate to let me know if something doesn’t work.

Where Next?

Popular in Guides/Tuts Top

Neurofunk
Hi folks! I wrote an article about BEAM and Haskell Interoperabilty. I'm describing the use of the erlang-ffi project, that impersonates ...
New
New
tobleron
Ok, so I am so excited to share with you the most interesting setup I have made for Elixir/Phoenix today. Why? Because if you trust me, i...
New
zachallaun
Hey friends, wanted to share a tiny shell script I’ve been using to start Livebook with easy access to either a running production server...
New
9mm
So I’m really loving elixir. BY FAR the most excruciating piece of learning a functional language for me is having to “transform” all my ...
New
redfloyd
Greetings fellow alchemists ! I have started to write an open-source interpreter in Elixir (https://github.com/nicolasdilley/dwarf-inter...
New
lukertty
Install web-mode and mmm-mode first and put this in your config file: (require 'mmm-mode) (require 'web-mode) (setq mmm-global-mode 'may...
New
f0rest8
Hi everyone, Just wanted to say that the new Self-referencing many to many guide is now up on the official Hex docs (at least I just not...
New
fuelen
Hi all! Just want to share a small code snippet which allows writing CASE expressions using macro which is similar to cond. Here is an ...
New
marcin
This post is intended to be a guide for others, I was running a remote debugger for the first time and appreciate feedback on how I could...
New

Other popular topics Top

Qqwy
Update: How to use the Blogs & Podcasts section You can post links to your blog posts or podcasts either in one of the Official Blog...
3268 119930 1237
New
chrismccord
Phoenix 1.4.0 released Phoenix 1.4 is out! This release ships with exciting new features, most notably with HTTP2 support, improved deve...
688 30048 115
New
srinivasu
How to handle excepions in elixir? Suppose i have A, B, C ,D, E modules. and each module has get() function. A.get() method will call th...
New
lessless
I believe there are people here who are dealing with CSV files import on the daily basis, and since Excel is a really popular tool there ...
New
albydarned
Hello all! I am typing this post from my new MacBook Pro with the M1 chip. I’m loving it so far, and will probably use it as my daily dr...
New
itssasanka
Hi all, Trying to get some more clarity over utc_datetime and naive_datetime for Ecto: https://hexdocs.pm/ecto/Ecto.Schema.html#module-...
New
msaraiva
Surface is an experimental library built on top of Phoenix LiveView and its new LiveComponent API that aims to provide a more declarative...
564 42633 214
New
baxterw3b
Hi guys, i’m new in the Elixir world, and i have to say, that i love it! i’m having some problem to understand anonymous functions with ...
New
lucidguppy
I have a super simple question about elixir - how would I take a file like this foo bar baz and output a new file that enumerates th...
New
aesmail
Hello guys, I have finally made it. I created an admin interface for a framework. It’s been on my todo list for years and with the curre...
New

We're in Beta

About us Mission Statement