Sanjibukai

Sanjibukai

Running an IEx session within an app (running as a release)?

Hello everybody,
Hope everyone is good!

TL;DR: I’m running a Phoenix app as a release where I didn’t defined anything about node configuration etc. (just ran ./prod/rel/my_app/bin/my_app start)
And I want to be able to run an IEx session in it, how can I do?

Edit: I changed the title. It was previously the following:
Best way to quickly read some ecto tables on a running application (within a release)


I am in a situation I thought it will be easy to solve but I’m finding it difficult..

I have an application running in production (deployed as a release).
It was planned to have some kind of a dashboard to see DB persisted data (and allowing to download them as CSV) but it’s not yet implemented (planned for later).
But now my customer realized it would be great if he had some data right now (before the end of the year for analysis purpose).. Something that doesn’t need to be implemented.. Just one shot of the raw data (as a CSV) will be good, even if it’s grabbed manually.
So I said, sure..
Since what he really now is only in one schema (for which I already have a context function like MySchema.list_all) that don’t even had that many entries (estimated around 20 based on payments data) I thought that I’ll simply connect to an iex session and run that expression embedded in some kind of pipeline with some Enum.map in order to format the output (it has some embedded schema).

Well, to begin with I’m unable to run iex because it’s a release and the container it’s running on doesn’t have iex installed..

When I run the following ps aux | grep elixir within the container, I’m getting the a result (the command) that have a --sname my_app_name and --setcookie RAnDomStriNg options.. So I was thinking to connect into the node, but I’m always getting a false after a couple of seconds.. I tried from my dev machine using the domain host but also from spinning up a docker container for that sole purpose on the server and connecting it to the same docker network. But I guess that won’t work anyway, because I don’t open any other port that 4000 on Phoenix. When I’m trying to do Node.connect :my_app_name I got an the error ** Cannot get connection id for node my_app_name. And when I try some kind of host combination I’m getting the error ** System NOT running to use fully qualified hostnames **

So I guess that I’m stuck not being able to run an IEx session on that running app, right?
But does anyone can confirm that or if there’s a way to still run IEx inside that release?
Also what could be done in order to make configure the release so that the next time I’ll be able to connect into it?

Now I’ll try to connect to the Postgres DB… Should be able to grab something I can make use of..

Anyway, thank you very much for any comment..

Marked As Solved

rodrigues

rodrigues

And I want to be able to run an IEx session in it, how can I do?

Hi @Sanjibukai something you can do is ssh into the machine and run rel/my_app/bin/my_app remote to connect to the running node. Does that work for you?

If you want to run iex locally in your local machine terminal to connect to the remote node, then that might be a bit more complicated, as it needs some SSH port forwarding, and passing iex options, but it’s also a possibility discussed here. This module could help you automate the port detection.

Also Liked

derek-zhou

derek-zhou

just ran ./prod/rel/my_app/bin/my_app start_iex?

rodrigues

rodrigues

Yes it does change them, it’s safer to not redefine modules in production environment for sure.

If you really need, you can just ensure it’s a new module name to not mess with others.

Where Next?

Popular in Questions Top

hariharasudhan94
lets say i have a sample like a = 20; b = 10; if (a > b) do {:ok, "a"} end if (a < b) do {:ok, b} end if (a == b) do {:ok, "equa...
New
9mm
I am constructing a JSON object (map) and I need to conditionally set a field. I’m trying to write proper elixir-way code… and I’m at a l...
New
Darmani72
If I have a post route which an argument: post /my_post_route/:my_param1, MyController.my_post_handler How would get the post params ...
New
Tee
can someone please explain to me how Enum.reduce works with maps
New
JeremM34
Hello, how can I check the Phoenix version ? Thanks !
New
pmjoe
I have a relationship of love and hate with Elixir. Lots of things are just absolutely right, but there are some things that are kind of ...
New
vrod
I am using the Starship cross-shell prompt – it seems pretty nice, but I get some errors: [WARN] - (starship::utils): Executing command ...
New
sergio_101
I am VERY much an elixir newbie. I have taken one elixir course and one phoenix course on Udemy. During that course, I saw the instructor...
New
openscript
Hello! Sorry for this astonishing simple question, but I’m really stuck. I try to set up the intellij-elixir plugin, but I don’t know ho...
New
jononomo
For some reason my phoenix channels are working for me in my local dev environment, but as soon as I deploy via Docker, I get a 403 error...
New

Other popular topics Top

WestKeys
Currently suffering from paralysis by [HTTP client] analysis. This is rather unusual in Elixirland as there tends to be consensus on the ...
New
Darmani72
If I have a post route which an argument: post /my_post_route/:my_param1, MyController.my_post_handler How would get the post params ...
New
baxterw3b
Hi guys, i’m new in the Elixir world, and i have to say, that i love it! i’m having some problem to understand anonymous functions with ...
New
pmjoe
I have a relationship of love and hate with Elixir. Lots of things are just absolutely right, but there are some things that are kind of ...
New
nobody
Hi! In PHP: $_SERVER[‘SERVER_ADDR’] - in Elixir? Searched the docs for ip address and the web, no good results. Thanks!
New
KronicDeth
Elixir plugin for JetBrain’s IntelliJ Platform (including Rubymine) This is a plugin that adds support for Elixir to JetBrains IntelliJ...
289 36352 110
New
Brian
What is the proper way to load a module from a file in to IEX? In the python world, doing something like this pretty standard: from ....
New
AstonJ
We’ve put together this wiki for Phoenix LiveView - please feel free to add any info you feel is worth including. What is Phoenix LiveV...
New
JakeBecker
TL;DR: I’ve just released an implementation of Microsoft’s IDE-independent Language Server Protocol for Elixir. It adds language support ...
1144 54120 245
New
sergio
Kind of like when jquery came out, it was super necessary. Existing drag and drop libraries have a bunch of baggage to support old browse...
New

Latest on Elixir Forum

Elixir Forum

We're in Beta

About us Mission Statement