Phoenix, Long-Running Process, and IEX

Hi Folks,

I have an umbrella project, where Phoenix is (for now) simply the HTTP interface.

I was banging my head against the wall because I was starting up a process in the iex console - iex -S mix - then making POST request to the Phoenix app and asking the Phoenix app to forward some data to the process I had started via iex (so that the process could do some work).

As most of you probably guessed by now, that process that was started in iex was not available to the Phoenix app. It was only after I created an endpoint in the Phoenix app to start the process, and THEN making the POST request, that everything started to work.

It seems to me that iex -S mix and mix phoenix.server started two separate BEAM instances and therefore couldn’t communicate. Is this correct? I’d like to know more about what is going on because this was an expensive lesson, so I’d like to make sure to learn it right.


1 Like

Just double-checking: have you started iex -S mix in a separate terminal window than mix phoenix.server? In that case these would be separate erlang VMs that by default don’t communicate with each other - you can start a phoenix server and iex by just doing: iex -S mix phoenix.server in which case all processes will be in the same VM.


@wojtekmach I did in fact start them in a new terminal window. More specifically, I use tmux, so I ran mix phoenix.server in one pane and iex -S mix in another.

Thank you for the command that will start both in the same VM.

I wonder if the command listed in the Phoenix Guides (heroku run "POOL_SIZE=2 iex -S mix") connects to the same VM.

@StevenXL unfortunately no, heroku run starts a one-off dyno which has a fresh VM. Btw, ere’re good SO answers on this topic: