Karsten S.
Karsten S.

Reputation: 2391

Alternative to restart phoenix.server without quitting

Is there any way to restart the mix phoenix.server besides of quitting (e.g. by CTRL+c twice or abort etc.) and starting it again?

The background for this is: I use foreman to start the phoenix server plus test runner etc. If I have to quit the server, everything is killed and I have to completely restart foreman. If I could just trigger a restart of the phoenix.server job everything else could remain running.

Since I use tmux and run the foreman commands in different panes this would help a lot. A command triggered via command line is also fine.

Upvotes: 4

Views: 3807

Answers (2)

Piyush
Piyush

Reputation: 31

you can also do :init.restart()

Upvotes: 2

Mike Buhot
Mike Buhot

Reputation: 4885

You can start your server in an iex session with

iex -S mix phx.server

Then stop, recompile and start the application with:

Application.stop(:your_app)
recompile()
Application.ensure_all_started(:your_app)

This should pick up any code changes and recreate the application supervision tree.

Upvotes: 5

Related Questions