How do I know if I am in iex -S mix

I have a Genserver that I want to run when the application start. This is not a big deal. I know how to do that

The problem is that I want it to run only when I run the server
I do not want it to run when I am using the iex -S mix

How do I do that?

I assume you’re running iex -S mix phx.server or mix phx.server and basically want to omit some element in the application supervision tree. Keep in mind that you’ll also probably consider mix release and other aspects.

That being said, you could easily inspect the application configuration here: https://github.com/phoenixframework/phoenix/blob/master/lib/mix/tasks/phx.server.ex#L34

If you know that Phoenix isn’t serving the endpoints, you can omit the worker specification in your supervision tree.

3 Likes

Just what I need

Thanks