Packages

Multi-surface application runtime for Elixir. One TEA module renders to terminal, browser (LiveView), SSH, and MCP (agents). 30+ widgets, flexbox + CSS grid, AI agent runtime, distributed swarm with CRDTs, time-travel debugging, session recording, sandboxed REPL, and agentic commerce.

Current section

Files

Jump to
raxol lib raxol core runtime shutdown_helper.ex
Raw

lib/raxol/core/runtime/shutdown_helper.ex

defmodule Raxol.Core.Runtime.ShutdownHelper do
@moduledoc """
Common utilities for graceful shutdown of runtime components.
"""
@doc """
Handles graceful shutdown of runtime components.
"""
def handle_shutdown(module_name, state) do
Raxol.Core.Runtime.Log.info_with_context(
"[#{module_name}] Received :shutdown cast for #{inspect(state.app_name)}. Stopping dependent processes..."
)
case state.dispatcher_pid do
nil ->
:ok
pid ->
Raxol.Core.Runtime.Log.info_with_context(
"[#{module_name}] Stopping Dispatcher PID: #{inspect(pid)}"
)
GenServer.stop(pid, :shutdown, :infinity)
end
case state.plugin_manager do
nil ->
:ok
pid ->
Raxol.Core.Runtime.Log.info_with_context(
"[#{module_name}] Stopping PluginManager PID: #{inspect(pid)}"
)
GenServer.stop(pid, :shutdown, :infinity)
end
{:stop, :normal, state}
end
end