mirror of
https://github.com/livebook-dev/livebook.git
synced 2025-03-03 18:35:41 +08:00
Ensure hostname is properly resolved when running in shortname distribution (#303)
* Ensure hostname is properly resolved when running in shortname distribution * Update lib/livebook/application.ex Co-authored-by: José Valim <jose.valim@dashbit.co> * Pretty print host resolution error * Add missing env var Co-authored-by: José Valim <jose.valim@dashbit.co>
This commit is contained in:
parent
ee027f7fd8
commit
d6c9ab1783
1 changed files with 22 additions and 0 deletions
|
@ -7,6 +7,7 @@ defmodule Livebook.Application do
|
|||
|
||||
def start(_type, _args) do
|
||||
ensure_distribution!()
|
||||
validate_hostname_resolution!()
|
||||
set_cookie()
|
||||
|
||||
# We register our own :standard_error below
|
||||
|
@ -83,6 +84,27 @@ defmodule Livebook.Application do
|
|||
end
|
||||
end
|
||||
|
||||
# See https://github.com/elixir-nx/livebook/issues/302
|
||||
defp validate_hostname_resolution!() do
|
||||
unless Livebook.Config.longname() do
|
||||
hostname = Livebook.Utils.node_host() |> to_charlist()
|
||||
|
||||
if :inet.gethostbyname(hostname) == {:error, :nxdomain} do
|
||||
Livebook.Config.abort!("""
|
||||
your hostname "#{hostname}" does not resolve to any IP address, which indicates something wrong in your OS configuration.
|
||||
|
||||
Make sure your computer's name resolves locally or start Livebook using a long distribution name. If you are using Livebook's CLI, you can:
|
||||
|
||||
livebook server --name livebook@127.0.0.1
|
||||
|
||||
If you are running it from source, do instead:
|
||||
|
||||
MIX_ENV=prod elixir --name livebook@127.0.0.1 -S mix phx.server
|
||||
""")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
defp set_cookie() do
|
||||
cookie = Application.fetch_env!(:livebook, :cookie)
|
||||
Node.set_cookie(cookie)
|
||||
|
|
Loading…
Reference in a new issue