Add FLAME support (#2629)

Co-authored-by: Jonatan Kłosko <jonatanklosko@gmail.com>
Co-authored-by: José Valim <jose.valim@gmail.com>
This commit is contained in:
Chris McCord 2024-06-07 14:58:48 -04:00 committed by GitHub
parent 3f02e0f30b
commit 8e4985be24
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 50 additions and 1 deletions

View file

@ -95,4 +95,4 @@ RUN chmod -R go=u $HOME
HEALTHCHECK CMD wget --no-verbose --tries=1 --spider http://localhost:${LIVEBOOK_PORT-8080}/public/health || exit 1
CMD [ "/app/bin/livebook", "start" ]
CMD [ "/app/bin/server" ]

11
rel/server/overlays/bin/server Executable file
View file

@ -0,0 +1,11 @@
#!/bin/sh
set -e
cd -P -- "$(dirname -- "$0")"
if [ -n "${FLAME_PARENT}" ]; then
epmd -daemon
elixir ./start_flame.exs
else
exec ./livebook start
fi

View file

@ -0,0 +1,38 @@
flame_parent = System.fetch_env!("FLAME_PARENT") |> Base.decode64!() |> :erlang.binary_to_term()
%{
pid: parent_pid,
flame_vsn: flame_parent_vsn,
backend: _backend,
backend_app: backend_app,
backend_vsn: backend_vsn,
node_base: node_base,
host_env: host_env
} = flame_parent
flame_node_name = :"#{node_base}@#{System.fetch_env!(host_env)}"
flame_node_cookie = String.to_atom(System.fetch_env!("LIVEBOOK_COOKIE"))
flame_dep =
if git_ref = System.get_env("FLAME_GIT_REF") do
{:flame, github: "phoenixframework/flame", ref: git_ref}
else
{:flame, flame_parent_vsn}
end
flame_backend_deps =
case backend_app do
:flame -> []
_ -> [{backend_app, backend_vsn}]
end
{:ok, _} = :net_kernel.start(flame_node_name, %{name_domain: :longnames})
Node.set_cookie(flame_node_cookie)
Mix.install([flame_dep | flame_backend_deps], consolidate_protocols: false)
IO.puts(
"[Livebook] starting #{inspect(flame_node_name)} in FLAME mode with parent: #{inspect(parent_pid)}, backend: #{inspect(backend_app)}"
)
System.no_halt(true)