mirror of
https://github.com/livebook-dev/livebook.git
synced 2025-10-25 12:56:13 +08:00
Add app service settings (#1116)
This commit is contained in:
parent
35b3fae3cb
commit
bfd47fd166
5 changed files with 61 additions and 3 deletions
12
README.md
12
README.md
|
|
@ -145,6 +145,12 @@ Livebook if said token is supplied as part of the URL.
|
||||||
|
|
||||||
The following environment variables configure Livebook:
|
The following environment variables configure Livebook:
|
||||||
|
|
||||||
|
* LIVEBOOK_APP_SERVICE_NAME - sets the application name used by the cloud
|
||||||
|
provider to aid debugging.
|
||||||
|
|
||||||
|
* LIVEBOOK_APP_SERVICE_URL - sets the application url to manage this
|
||||||
|
Livebook instance within the cloud provider platform.
|
||||||
|
|
||||||
* LIVEBOOK_COOKIE - sets the cookie for running Livebook in a cluster.
|
* LIVEBOOK_COOKIE - sets the cookie for running Livebook in a cluster.
|
||||||
Defaults to a random string that is generated on boot.
|
Defaults to a random string that is generated on boot.
|
||||||
|
|
||||||
|
|
@ -157,6 +163,9 @@ The following environment variables configure Livebook:
|
||||||
"attached:NODE:COOKIE" (Attached node) or "embedded" (Embedded).
|
"attached:NODE:COOKIE" (Attached node) or "embedded" (Embedded).
|
||||||
Defaults to "standalone".
|
Defaults to "standalone".
|
||||||
|
|
||||||
|
* LIVEBOOK_FORCE_SSL_HOST - sets a host to redirect to if the request is not over HTTP.
|
||||||
|
Note it does not apply when accessing Livebook via localhost. Defaults to nil.
|
||||||
|
|
||||||
* LIVEBOOK_HOME - sets the home path for the Livebook instance. This is the
|
* LIVEBOOK_HOME - sets the home path for the Livebook instance. This is the
|
||||||
default path used on file selection screens and others. Defaults to the
|
default path used on file selection screens and others. Defaults to the
|
||||||
user's operating system home.
|
user's operating system home.
|
||||||
|
|
@ -187,9 +196,6 @@ The following environment variables configure Livebook:
|
||||||
Enabled by default unless `LIVEBOOK_PASSWORD` is set. Set it to "false" to
|
Enabled by default unless `LIVEBOOK_PASSWORD` is set. Set it to "false" to
|
||||||
disable it.
|
disable it.
|
||||||
|
|
||||||
* LIVEBOOK_FORCE_SSL_HOST - set a host to redirect to if the request is not over HTTP.
|
|
||||||
Note it does not apply when accessing Livebook via localhost. Defaults to nil.
|
|
||||||
|
|
||||||
<!-- Environment variables -->
|
<!-- Environment variables -->
|
||||||
|
|
||||||
If running Livebook as a Docker image or an Elixir release, [the environment
|
If running Livebook as a Docker image or an Elixir release, [the environment
|
||||||
|
|
|
||||||
|
|
@ -20,6 +20,8 @@ config :mime, :types, %{
|
||||||
}
|
}
|
||||||
|
|
||||||
config :livebook,
|
config :livebook,
|
||||||
|
app_service_name: nil,
|
||||||
|
app_service_url: nil,
|
||||||
authentication_mode: :token,
|
authentication_mode: :token,
|
||||||
explore_notebooks: [],
|
explore_notebooks: [],
|
||||||
plugs: [],
|
plugs: [],
|
||||||
|
|
|
||||||
|
|
@ -147,6 +147,14 @@ defmodule Livebook do
|
||||||
Livebook.Config.cookie!("LIVEBOOK_COOKIE") ||
|
Livebook.Config.cookie!("LIVEBOOK_COOKIE") ||
|
||||||
Livebook.Config.cookie!("RELEASE_COOKIE") ||
|
Livebook.Config.cookie!("RELEASE_COOKIE") ||
|
||||||
Livebook.Utils.random_cookie()
|
Livebook.Utils.random_cookie()
|
||||||
|
|
||||||
|
if app_service_name = Livebook.Config.app_service_name!("LIVEBOOK_APP_SERVICE_NAME") do
|
||||||
|
config :livebook, :app_service_name, app_service_name
|
||||||
|
|
||||||
|
config :livebook,
|
||||||
|
:app_service_url,
|
||||||
|
Livebook.Config.app_service_url!("LIVEBOOK_APP_SERVICE_URL")
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@doc """
|
@doc """
|
||||||
|
|
|
||||||
|
|
@ -106,6 +106,22 @@ defmodule Livebook.Config do
|
||||||
Application.fetch_env!(:livebook, :shutdown_enabled)
|
Application.fetch_env!(:livebook, :shutdown_enabled)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@doc """
|
||||||
|
Returns the application service name.
|
||||||
|
"""
|
||||||
|
@spec app_service_name() :: String.t() | nil
|
||||||
|
def app_service_name() do
|
||||||
|
Application.fetch_env!(:livebook, :app_service_name)
|
||||||
|
end
|
||||||
|
|
||||||
|
@doc """
|
||||||
|
Returns the application service url.
|
||||||
|
"""
|
||||||
|
@spec app_service_url() :: String.t() | nil
|
||||||
|
def app_service_url() do
|
||||||
|
Application.fetch_env!(:livebook, :app_service_url)
|
||||||
|
end
|
||||||
|
|
||||||
## Parsing
|
## Parsing
|
||||||
|
|
||||||
@doc """
|
@doc """
|
||||||
|
|
@ -224,6 +240,20 @@ defmodule Livebook.Config do
|
||||||
System.get_env(env)
|
System.get_env(env)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@doc """
|
||||||
|
Parses application service name from env.
|
||||||
|
"""
|
||||||
|
def app_service_name!(env) do
|
||||||
|
System.get_env(env)
|
||||||
|
end
|
||||||
|
|
||||||
|
@doc """
|
||||||
|
Parses application service url from env.
|
||||||
|
"""
|
||||||
|
def app_service_url!(env) do
|
||||||
|
System.get_env(env)
|
||||||
|
end
|
||||||
|
|
||||||
@doc """
|
@doc """
|
||||||
Parses and validates default runtime from env.
|
Parses and validates default runtime from env.
|
||||||
"""
|
"""
|
||||||
|
|
|
||||||
|
|
@ -50,6 +50,18 @@ defmodule LivebookWeb.SettingsLive do
|
||||||
</h1>
|
</h1>
|
||||||
<div class="flex items-center justify-between border border-gray-200 rounded-lg p-4">
|
<div class="flex items-center justify-between border border-gray-200 rounded-lg p-4">
|
||||||
<div class="flex items-center space-x-12">
|
<div class="flex items-center space-x-12">
|
||||||
|
<%= if app_name = Livebook.Config.app_service_name() do %>
|
||||||
|
<div class="flex flex-col space-y-1">
|
||||||
|
<span class="text-sm text-gray-500">Application</span>
|
||||||
|
<span class="text-gray-800 text-sm font-semibold">
|
||||||
|
<%= if app_url = Livebook.Config.app_service_url() do %>
|
||||||
|
<a href={app_url} target="_blank"><%= app_name %></a>
|
||||||
|
<% else %>
|
||||||
|
<%= app_name %>
|
||||||
|
<% end %>
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
<% end %>
|
||||||
<.labeled_text label="Livebook" text={"v#{Application.spec(:livebook, :vsn)}"} />
|
<.labeled_text label="Livebook" text={"v#{Application.spec(:livebook, :vsn)}"} />
|
||||||
<.labeled_text label="Elixir" text={"v#{System.version()}"} />
|
<.labeled_text label="Elixir" text={"v#{System.version()}"} />
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue