From a0b3d1fb854887dccfe48a7fbfbb27920fcc8581 Mon Sep 17 00:00:00 2001 From: v0idpwn Date: Thu, 6 Apr 2023 22:07:41 +0200 Subject: [PATCH] Improve crash handling --- lib/kafkaesque/pipeline.ex | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/lib/kafkaesque/pipeline.ex b/lib/kafkaesque/pipeline.ex index b8e6b05..75a53ba 100644 --- a/lib/kafkaesque/pipeline.ex +++ b/lib/kafkaesque/pipeline.ex @@ -18,6 +18,7 @@ defmodule Kafkaesque.Pipeline do GenServer.start_link(__MODULE__, opts) end + @impl GenServer def init(opts) do Process.flag(:trap_exit, true) @@ -41,6 +42,12 @@ defmodule Kafkaesque.Pipeline do }} end + @impl GenServer + def handle_info({:EXIT, _pid, reason}, state) do + {:stop, reason, state} + end + + @impl GenServer def terminate(:shutdown, state) do # Drain :ok = Producer.stop_producing(state.producer)