Elixir/Erlang offers Observer a GUI tool for observing the Elixir/Erlang system
In this article, we will set up the Observer for remotely connecting to the mix release
deployed Elixir app.
Let's start, in your Elixir app, run.
mix release.init
You will notice, it generates three files in rel
folder asenv.bat.eex
, env.sh.eex
and vm.args.eex
Uncomment following lines in env.sh.eex
file
export RELEASE_DISTRIBUTION=name
export RELEASE_NODE=<%= @release.name %>@127.0.0.1
We need to add the release name and cookie. A cookie is used to remotely connect to the app's node with a distributed feature of Elixir.
export RELEASE_NAME="your_app"
export RELEASE_COOKIE="pa55word"
Alternatively, for release name and cookie, you can add :releases
key in mix.exs
in project function as below
deps: deps(),
releases: [
your_app: [
version: "0.0.1",
include_executables_for: [:unix],
applications: [runtime_tools: :permanent],
cookie: "pa55word"
]
]
Now go and deploy the app to your production/staging instance with commands provided by mix release.
To connect with the remote app, we need to know the port attached by epmd for attaching to our Phoenix application deployed on the server.
On your server, go to erts/bin directory and run epmd -names
prod/rel/your_app/erts-11.0/bin$ epmd -names
epmd: up and running on port 4369 with data:
name your_app at port 40573
Let's call 40573 as PORT; we will need it to set up an ssh tunnel from our local machine terminal.
Once the app runs on production/staging, you deploy it with mix release, run the below command in a local terminal.
ssh -N -L PORT:localhost:PORT -L 4369:localhost:4369 ubuntu@your_server_ip
Now run this in another terminal.
erl -name debug@127.0.0.1 -setcookie 'pa55word' -run observer
Observer window will open, and you go to menu item 'Nodes,' and there you will find out your_app@127.0.0.1,
Click it, and you will see the Observer showing your app's processes and other data.