Skip to content

Commit

Permalink
fix: add more logging to runtime startup
Browse files Browse the repository at this point in the history
  • Loading branch information
mhanberg committed Feb 27, 2024
1 parent 10ccb14 commit 91fb590
Showing 1 changed file with 46 additions and 31 deletions.
77 changes: 46 additions & 31 deletions lib/next_ls/runtime.ex
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,50 @@ defmodule NextLS.Runtime do
|> Path.join("cmd")
|> Path.absname()

NextLS.Logger.info(logger, "Using `elixir` found at: #{elixir_exe}")
env = [
{~c"LSP", ~c"nextls"},
{~c"NEXTLS_PARENT_PID", parent},
{~c"MIX_ENV", ~c"#{mix_env}"},
{~c"MIX_TARGET", ~c"#{mix_target}"},
{~c"MIX_BUILD_ROOT", ~c".elixir-tools/_build"},
{~c"ROOTDIR", false},
{~c"BINDIR", false},
{~c"RELEASE_ROOT", false},
{~c"RELEASE_SYS_CONFIG", false},
{~c"PATH", String.to_charlist(new_path)}
]

args =
[elixir_exe] ++
if @env == :test do
["--erl", "-kernel prevent_overlapping_partitions false"]
else
[]
end ++
[
"--no-halt",
"--sname",
sname,
"--cookie",
Node.get_cookie(),
"-S",
"mix",
"loadpaths",
"--no-compile"
]

NextLS.Logger.info(logger, """
Booting runtime for #{name}.
- elixir: #{elixir_exe}
- zombie wrapper script: #{exe}
- working_dir: #{working_dir}
- command: #{Enum.join(args, " ")}
Environment:
#{Enum.map_join(env, "\n", fn {k, v} -> "#{k}=#{v}" end)}
""")

port =
Port.open(
Expand All @@ -128,36 +171,8 @@ defmodule NextLS.Runtime do
:binary,
:stream,
cd: working_dir,
env: [
{~c"LSP", ~c"nextls"},
{~c"NEXTLS_PARENT_PID", parent},
{~c"MIX_ENV", ~c"#{mix_env}"},
{~c"MIX_TARGET", ~c"#{mix_target}"},
{~c"MIX_BUILD_ROOT", ~c".elixir-tools/_build"},
{~c"ROOTDIR", false},
{~c"BINDIR", false},
{~c"RELEASE_ROOT", false},
{~c"RELEASE_SYS_CONFIG", false},
{~c"PATH", String.to_charlist(new_path)}
],
args:
[elixir_exe] ++
if @env == :test do
["--erl", "-kernel prevent_overlapping_partitions false"]
else
[]
end ++
[
"--no-halt",
"--sname",
sname,
"--cookie",
Node.get_cookie(),
"-S",
"mix",
"loadpaths",
"--no-compile"
]
env: env,
args: args
]
)

Expand Down

0 comments on commit 91fb590

Please sign in to comment.