mirror of
https://github.com/livebook-dev/livebook.git
synced 2025-03-03 18:35:41 +08:00
parent
5190e01db7
commit
dee372c623
3 changed files with 28 additions and 2 deletions
|
@ -39,16 +39,39 @@ defmodule Livebook.Application do
|
|||
|
||||
defp ensure_distribution!() do
|
||||
unless Node.alive?() do
|
||||
System.cmd("epmd", ["-daemon"])
|
||||
case System.cmd("epmd", ["-daemon"]) do
|
||||
{_, 0} ->
|
||||
:ok
|
||||
|
||||
_ ->
|
||||
abort!("""
|
||||
could not start epmd (Erlang Port Mapper Driver). Livebook uses epmd to \
|
||||
talk to different runtimes. You may have to start epmd explicitly by calling:
|
||||
|
||||
epmd -daemon
|
||||
|
||||
Or by calling:
|
||||
|
||||
elixir --sname test -e "IO.puts node()"
|
||||
|
||||
Then you can try booting Livebook again
|
||||
""")
|
||||
end
|
||||
|
||||
{type, name} = get_node_type_and_name()
|
||||
|
||||
case Node.start(name, type) do
|
||||
{:ok, _} -> :ok
|
||||
{:error, _} -> raise "failed to start distributed node"
|
||||
{:error, reason} -> abort!("could not start distributed node: #{inspect(reason)}")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
defp abort!(message) do
|
||||
IO.puts("\nERROR!!! [Livebook] " <> message)
|
||||
System.halt(1)
|
||||
end
|
||||
|
||||
defp get_node_type_and_name() do
|
||||
Application.get_env(:livebook, :node) || {:shortnames, random_short_name()}
|
||||
end
|
||||
|
|
|
@ -55,7 +55,9 @@ defmodule Livebook.Runtime.ElixirStandalone do
|
|||
defp start_elixir_node(elixir_path, node_name, eval) do
|
||||
# Here we create a port to start the system process in a non-blocking way.
|
||||
Port.open({:spawn_executable, elixir_path}, [
|
||||
:binary,
|
||||
:nouse_stdio,
|
||||
:hide,
|
||||
args: elixir_flags(node_name) ++ ["--eval", eval]
|
||||
])
|
||||
end
|
||||
|
|
|
@ -91,6 +91,7 @@ defmodule Livebook.Runtime.MixStandalone do
|
|||
Port.open({:spawn_executable, elixir_path}, [
|
||||
:binary,
|
||||
:stderr_to_stdout,
|
||||
:hide,
|
||||
args: elixir_flags(node_name) ++ ["-S", "mix", "run", "--eval", eval],
|
||||
cd: project_path
|
||||
])
|
||||
|
|
Loading…
Reference in a new issue