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
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
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:
Notice however, that doing so will kick out of your IEX session after ![]()
Hope it helps!
Popular in Questions
Other popular topics
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #channels
- #elixirconf
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixir-ls
- #phoenix_html
- #iex
- #blog-post
- #graphql
- #genstage
- #ai
- #websockets
- #supervisor
- #advent-of-code
- #elixirconf-us
- #distillery
- #processes
- #forms
- #api
- #metaprogramming
- #security
- #performance









