mirror of
https://github.com/livebook-dev/livebook.git
synced 2024-09-20 18:15:56 +08:00
Log the reason a runtime node goes down (#1368)
Co-authored-by: Jonatan Kłosko <jonatanklosko@gmail.com>
This commit is contained in:
parent
aca9c18086
commit
895373e08b
|
@ -182,7 +182,6 @@ defmodule Livebook.Session do
|
|||
* `{:hydrate_bin_entries, entries}`
|
||||
* `{:operation, operation}`
|
||||
* `{:error, error}`
|
||||
* `{:info, info}`
|
||||
|
||||
"""
|
||||
@spec subscribe(id()) :: :ok | {:error, term()}
|
||||
|
@ -967,8 +966,11 @@ defmodule Livebook.Session do
|
|||
end
|
||||
|
||||
@impl true
|
||||
def handle_info({:DOWN, ref, :process, _, _}, %{runtime_monitor_ref: ref} = state) do
|
||||
broadcast_info(state.session_id, "runtime node terminated unexpectedly")
|
||||
def handle_info({:DOWN, ref, :process, _, reason}, %{runtime_monitor_ref: ref} = state) do
|
||||
broadcast_error(
|
||||
state.session_id,
|
||||
"runtime node terminated unexpectedly - #{Exception.format_exit(reason)}"
|
||||
)
|
||||
|
||||
{:noreply,
|
||||
%{state | runtime_monitor_ref: nil}
|
||||
|
@ -1511,10 +1513,6 @@ defmodule Livebook.Session do
|
|||
broadcast_message(session_id, {:error, error})
|
||||
end
|
||||
|
||||
defp broadcast_info(session_id, info) do
|
||||
broadcast_message(session_id, {:info, info})
|
||||
end
|
||||
|
||||
defp broadcast_message(session_id, message) do
|
||||
Phoenix.PubSub.broadcast(Livebook.PubSub, "sessions:#{session_id}", message)
|
||||
end
|
||||
|
|
|
@ -1106,12 +1106,6 @@ defmodule LivebookWeb.SessionLive do
|
|||
{:noreply, put_flash(socket, :error, message)}
|
||||
end
|
||||
|
||||
def handle_info({:info, info}, socket) do
|
||||
message = info |> to_string() |> upcase_first()
|
||||
|
||||
{:noreply, put_flash(socket, :info, message)}
|
||||
end
|
||||
|
||||
def handle_info({:hydrate_bin_entries, hydrated_entries}, socket) do
|
||||
hydrated_entries_map = Map.new(hydrated_entries, fn entry -> {entry.cell.id, entry} end)
|
||||
|
||||
|
|
|
@ -513,7 +513,7 @@ defmodule Livebook.SessionTest do
|
|||
|
||||
assert_receive {:operation, {:set_runtime, _, runtime}}
|
||||
refute Runtime.connected?(runtime)
|
||||
assert_receive {:info, "runtime node terminated unexpectedly"}
|
||||
assert_receive {:error, "runtime node terminated unexpectedly - no connection"}
|
||||
end
|
||||
|
||||
test "on user change sends an update operation subscribers", %{session: session} do
|
||||
|
|
Loading…
Reference in a new issue