engineeringdept

engineeringdept

Os_mon errors during shutdown on Heroku - advice on where to solve this?

OK, here’s a tricky issue, and I’m looking for a bit of advice about where to solve it…

We just enabled the New Relic agent in our Elixir app. It uses os_mon, from OTP, to poll for the cpu utilisation and report it back to New Relice. cpu_sup, the part of os_mon that deals with CPU reporting, uses a port subprocess, also called cpu_sup, to hook into the OS and retrieve the utilisation/load/etc.

Our application runs on Heroku. During the shutdown of a dyno, Heroku sends a SIGTERM to all processes, whether child or not. BEAM detects this and starts to shut down the applications in sequence. But the cpu_sup subprocess also receives this and immediately exits. The next time the New Relic agent polls, the cpu_sup GenServer process blows up with a ArgumentError as the port is no longer running.

So, where should we resolve this?

Is it a bug in Erlang/OTP that cpu_sup responds to a SIGTERM? I’m not sure what’s expected of ports here, but it feels like it’s important to be able to exit a detached subprocess with SIGTERM, if that ever occurs. I’m not convinced this process is doing anything wrong, per se.

Or is this an issue in Heroku that it sends SIGTERM to all processes, not just the parent/root process? If we controlled the OS and supervisor we wouldn’t send SIGTERM to all processes, but I can see why they do this. And I can’t see how we prevent it, at the moment.

Or can we trap this in the New Relic agent? I’m not sure how this would work, without trapping exits from the cpu_sup GenServer process, which feels a bit nasty.

Or should we just give in and ignore these errors in our exception tracking?

Any thoughts?

Where Next?

Popular in Questions Top

New
tduccuong
Hi, is there any work on GUI with Elixir, that is similar to Electron/Javascript? My idea is to bundle Phoenix and BEAM into a single se...
New
stefanchrobot
What’s the safe way to decode a JSON string into a struct? I want to avoid calling String.to_atom. Jason.decode can give me a map with st...
New
ycv005
I have followed this StackOverflow post to install the specific version of Erlang. And When I am running mix ecto.setup then getting fol...
New
alice
Hey, Just curious what are the main benefits of Elixir compared to Clojure? When is Elixir more useful than Clojure and vice versa? Th...
New
SoCreat
i’m a new one to elixir which editor can i use vs code? or atom? Thanks! :smiley:
New
nobody
Hi! In PHP: $_SERVER[‘SERVER_ADDR’] - in Elixir? Searched the docs for ip address and the web, no good results. Thanks!
New
fayddelight
I tried installing elixir 1.11.2 erlang 23.3.4 via asdf in my zsh shell. Enabled the versions locally and globally. When I list them ...
New
shijith.k
I am trying to start a new phoenix project with elixir 1.9, but mix phx.new does not work. It says that ** (Mix) The task "phx.new" could...
New
vonH
In asking this question I am more interested about the expressiveness of the language itself and less concerned about the availability of...
New

Other popular topics 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
sorentwo
Hello! tl;dr Announcing Oban, an Ecto based job processing library with a focus on reliability and historical observability. After spen...
985 43487 311
New
TunkShif
This post is an instruction guide to help you setup your Neovim for Elixir development from scratch. It includes general information on h...
274 41989 114
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
stefanluptak
Hello everybody, usually, I use a 29" ultra-wide monitor for VSCode which can easily accomodate explorer (files panel) + file with code ...
New
gausby
I asked this very same question on twitter and got some interesting feedback, but I thought it would be a good question to ask here as we...
1207 39467 209
New
boundedvariable
I am going through the kafka architecture. All the features what the kafka is providing are already in Erlang. I would like hear your opi...
New
komlanvi
Hi everyone, I was playing with phoenix liveView but I run into an issue. I have a form and want to validate each input text when the te...
New
jaysoifer
Is there a way to rollback a specific migration and only that one (“skipping” all the other ones)? Would mix ecto.rollback -v 200809061...
New
svb
Hi! Currently I want to submit a form by pressing the Enter key. However, since my input field is of type “textarea” this is just adds a...
New

Latest on Elixir Forum

Elixir Forum

We're in Beta

About us Mission Statement