Confused about how to write a CLI that for a elixir app running as a system service

I’ve slowly been learning Elixir over the last year. For the fun of it, I wrote an app that simulates the data for a ride sharing company: drivers, riders, pickups, drop offs. I’ve only run it from mix but it eventually need to be a running service. I haven’t looked into the details of distilley yet but that’s on the list for making an app that is a service that starts and runs on boot.

What I’m trying to figure out now is how to write a CLI app, that can speak to a running Elixir service. I just have some simple needs to send commands to the service: start, stop, pause, change parameters, etc…

I know I’m probably missing something obvious, but I’m bouncing around using this project to force me to learn a variety of use cases for elixir/beam. Any ideas of how I can accomplish this or thoughts of where I can find pieces of the puzzle I’m trying to solve?


Either define an HTTP API that you use to send commands, or use a UNIX domain socket to do so, or use distillery and custom tasks.

1 Like

If you are talking to another Elixir application you can also do direct message passing to a registered named process.

Usually we would have one entry point process/application. If you need a non-Elixir interface this application can also manage a REST interface. In this day and age I would shy away from sockets in favour of HTTP REST interface, but my initial attempt would be message passing to a registered named process.

I also favour custom tasks because it makes it very easy to create shell scripts to interact with the system.