Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to start Phoenix server when you are already in iex?

I know we can launch iex -S mix phoenix.server. But say I am already in iex -S mix. What can I do to get the server started?

Thank you.

like image 872
user3066199 Avatar asked Nov 26 '25 07:11

user3066199


1 Answers

It's maybe not a great way of doing it, but I'm imagining you're only doing this in dev anyway. But one way of doing it would be to set the same config option mix phx.server sets then restarting your endpoint (this example stops it and lets the app supervisor restart it).

iex> Application.put_env(:phoenix, :serve_endpoints, true)
:ok
iex> GenServer.stop(MyAppWeb.Endpoint)
:ok
[info] Running MyAppWeb.Endpoint with cowboy 2.9.0 at 0.0.0.0:4000 (http)
like image 58
Brett Beatty Avatar answered Nov 29 '25 10:11

Brett Beatty



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!