Support configuring Attached as the default runtime (#397)

* Support configuring Attached as the default runtime

* Wrap env options section in the README
This commit is contained in:
Jonatan Kłosko 2021-06-24 18:03:00 +02:00 committed by GitHub
parent 2cded9f27d
commit 0061facd64
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 35 additions and 9 deletions

View file

@ -126,20 +126,28 @@ The following environment variables configure Livebook:
* LIVEBOOK_COOKIE - sets the cookie for running Livebook in a cluster.
Defaults to a random string that is generated on boot.
* LIVEBOOK_DEFAULT_RUNTIME - sets the runtime type that is used
by default when none is started explicitly for the given notebook.
Must be either "standalone" (Elixir standalone), "mix[:path]" (Mix standalone)
or "embedded" (Embedded). Defaults to "standalone".
* LIVEBOOK_DEFAULT_RUNTIME - sets the runtime type that is used by default
when none is started explicitly for the given notebook. Must be either
"standalone" (Elixir standalone), "mix[:PATH]" (Mix standalone),
"attached:NODE:COOKIE" (Standalone) or "embedded" (Embedded).
Defaults to "standalone".
* LIVEBOOK_IP - sets the ip address to start the web application on. Must be a valid IPv4 or IPv6 address.
* LIVEBOOK_IP - sets the ip address to start the web application on.
Must be a valid IPv4 or IPv6 address.
* LIVEBOOK_PASSWORD - sets a password that must be used to access Livebook. Must be at least 12 characters. Defaults to token authentication.
* LIVEBOOK_PASSWORD - sets a password that must be used to access Livebook.
Must be at least 12 characters. Defaults to token authentication.
* LIVEBOOK_PORT - sets the port Livebook runs on. If you want multiple instances to run on the same domain but different ports, you also need to set 'LIVEBOOK_SECRET_KEY_BASE'. Defaults to 8080.
* LIVEBOOK_PORT - sets the port Livebook runs on. If you want multiple instances
to run on the same domain but different ports, you also need to set 'LIVEBOOK_SECRET_KEY_BASE'.
Defaults to 8080.
* LIVEBOOK_ROOT_PATH - sets the root path to use for file selection.
* LIVEBOOK_SECRET_KEY_BASE - sets a secret key that is used to sign and encrypt the session and other payloads used by Livebook. Must be at least 64 characters long and it can be generated by commands such as: 'openssl rand -base64 48'. Defaults to a random secret on every boot.
* LIVEBOOK_SECRET_KEY_BASE - sets a secret key that is used to sign and encrypt
the session and other payloads used by Livebook. Must be at least 64 characters
long and it can be generated by commands such as: 'openssl rand -base64 48'.
Defaults to a random secret on every boot.
<!-- Environment variables -->

View file

@ -177,6 +177,10 @@ defmodule Livebook.Config do
abort!(~s{"#{path}" does not point to a Mix project})
end
"attached:" <> config ->
{node, cookie} = parse_connection_config!(config)
{Livebook.Runtime.Attached, [node, cookie]}
other ->
abort!(
~s{expected #{context} to be either "standalone", "mix[:path]" or "embedded", got: #{inspect(other)}}
@ -195,6 +199,19 @@ defmodule Livebook.Config do
end
end
defp parse_connection_config!(config) do
[node, cookie] = String.split(config, ":", parts: 2)
unless node =~ "@" do
abort!(~s{expected node to include hostname, got: #{inspect(node)}})
end
node = String.to_atom(node)
cookie = String.to_atom(cookie)
{node, cookie}
end
@doc """
Aborts booting due to a configuration error.
"""

View file

@ -24,7 +24,8 @@ defmodule LivebookCLI.Server do
explicitly for the given notebook, defaults to standalone
Supported options:
* standalone - Elixir standalone
* mix[:path] - Mix standalone
* mix[:PATH] - Mix standalone
* attached:NODE:COOKIE - Attached
* embedded - Embedded
--ip The ip address to start the web application on, defaults to 127.0.0.1
Must be a valid IPv4 or IPv6 address