Disable ETS persistence for Agent and CLI hubs

This commit is contained in:
Alexandre de Souza 2025-07-23 17:00:33 -03:00
parent ce0b7b2e54
commit ecfa69788a
No known key found for this signature in database
GPG key ID: 29C8CC410E3F1BD0
4 changed files with 22 additions and 3 deletions

View file

@ -157,6 +157,10 @@ defmodule Livebook do
config :livebook, teams_url: url, warn_on_live_teams_server: false
end
if System.get_env("LIVEBOOK_TEAMS_AUTH") do
config :livebook, :persist_storage, false
end
if Livebook.Config.boolean!("LIVEBOOK_SHUTDOWN_ENABLED", false) do
config :livebook, :shutdown_callback, {System, :stop, []}
end

View file

@ -186,10 +186,17 @@ defmodule Livebook.Storage do
# in case it is persisting to disk. terminate/2 is still a no-op.
Process.flag(:trap_exit, true)
table = load_or_create_table()
:persistent_term.put(__MODULE__, table)
persist_storage? = Application.get_env(:livebook, :persist_storage, true)
{:ok, %{table: table}}
table =
if persist_storage? do
load_or_create_table()
else
:ets.new(__MODULE__, [:protected, :duplicate_bag])
end
:persistent_term.put(__MODULE__, table)
{:ok, %{table: table, persist?: persist_storage?}}
end
@impl true
@ -220,6 +227,10 @@ defmodule Livebook.Storage do
end
@impl true
def handle_continue(:save_to_file, %{persist?: false} = state) do
{:noreply, state}
end
def handle_continue(:save_to_file, %{table: table} = state) do
file_path = String.to_charlist(config_file_path())
:ok = :ets.tab2file(table, file_path)

View file

@ -21,6 +21,7 @@ defmodule LivebookCLI do
extract_priv!()
:ok = Application.load(:livebook)
Application.put_env(:livebook, :persist_storage, false)
if unix?() do
Application.put_env(:elixir, :ansi_enabled, true)

View file

@ -38,6 +38,9 @@ Application.put_env(:livebook, Livebook.Runtime.Embedded,
load_packages: {Livebook.Runtime.Embedded.Packages, :list, []}
)
# Disable ETS disk persistence
Application.put_env(:livebook, :persist_storage, false)
# Disable autosaving
Livebook.Storage.insert(:settings, "global", autosave_path: nil)