Ordermind

Ordermind

Recompile and restart applications from the outside?

Hi, I’m currently building a small REST api in Elixir and in order to learn the basics better I’m not using Phoenix, just Cowboy and Plug. Whenever I change a file I want to recompile and restart the (umbrella) application so that the changes are visible on the next request during development. At this time I’m restarting the whole docker container, but I’m wondering if there is a better way. Ideally I would like to have something like “mix app.restart” but that sort of command doesn’t seem to exist. How would you guys solve this problem?

Marked As Solved

Ordermind

Ordermind

I’ve come up with what I think is the perfect solution now: If I name the elixir node when starting it via mix run, I can then remote shell into it with iex and recompile it, and then it works. That should be the fastest way for sure. Here’s the commands for anyone that comes across this problem later:

Start a named elixir node: elixir --sname <node name> -S mix run --no-halt
Remote shell with iex: iex --remsh <name@host> --sname <just make up a name>

Also Liked

Fl4m3Ph03n1x

Fl4m3Ph03n1x

Indeed you can remotely connect to the shell and once there you can use the recompile command to recompile your code. But how will you restart it after?

A way of doing it is to restart BEAM. You can do this by typing :init.restart. It returns :ok and proceeds to restart all applications smoothly:

http://erlang.org/doc/man/init.html

Notice however, that doing so will kick out of your IEX session after :stuck_out_tongue:

Hope it helps!

Where Next?

Popular in Questions Top

senggen
Erlang/OTP 25 [erts-13.2.2] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1] 15:22:35.803 [error] gen_event {lager_file_backend...
New
sergio
In Ruby, I can go: User.find_by(email: "foobar@email.com").update(email: "hello@email.com") How can I do something similar in Elixir? ...
New
gshaw
What is the idiomatic way of matching for not nil in Elixir? E.g., First way: defp halt_if_not_signed_in(conn, signed_in_account) when...
New
jerry
Good day to you all. I have been struggling to get a query involving like and ilike to work. Can anyone assist me on this, please? pro...
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
polypush135
As many of you may have realized by now (sorry for all the posts here) I’ve been working on a db problem where I’m trying to aggregate a ...
New
myronmarston
The Elixir Typespec docs show the following syntax for keyword lists in typespecs: # ... | [key: type] # keyword lis...
New
qwerescape
Is there a way to get the call stack or stack trace at any point in the code? Not from exceptions, but an expression that returns how the...
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
Mooodi
Given a string, how can I get access to its character by index? Enum.at("my_string", 2) doesn't work. Or rather, not char, but a substr...
New

Other popular topics Top

JorisKok
I have a server on AWS, and was running a load test using artillery. When looking at the Phoenix dashboard I see the Ports going to 100% ...
New
aalberti333
As the title describes, I’m trying to run Enum.map() over a list of key/value pairs, where the value is a map. My data looks like this: ...
New
sergio
I couldn’t find any guides that worked well with Phoenix 1.6.0 and esbuild. I hope this helps people test the waters and eases you into t...
New
New
quazar
How to set Jason to encode all fields in ecto schema, I don’t care about security and implementing only is taking long list of attributes...
New
johnnyicon
Hi all, I've just started learning Elixir and Phoenix Framework, so please pardon my n00bness at this stage. I'm trying to use Postg...
New
electic
Hi, I am new to Elixir. I am trying to use the DateTime component to insert a date into MySQL however the there seems to be no way to fo...
New
skosch
To my knowledge, put_in, Map.update etc. all have the one limitation of not automatically creating intermediate keys when needed (for exa...
New
jay1
Why is it that the mnesia database isn’t the most preferred database for use in Elixir/Phoenix?
New
magnetic
Hey :wave:t3: Elixir community, I’ve been learning Elixir, and working on some side projects. My editor of choice is VSCode, and althoug...
New

We're in Beta

About us Mission Statement