Skip to content

Commit 91fb590

Browse files
committed
fix: add more logging to runtime startup
1 parent 10ccb14 commit 91fb590

File tree

1 file changed

+46
-31
lines changed

1 file changed

+46
-31
lines changed

lib/next_ls/runtime.ex

Lines changed: 46 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,50 @@ defmodule NextLS.Runtime do
117117
|> Path.join("cmd")
118118
|> Path.absname()
119119

120-
NextLS.Logger.info(logger, "Using `elixir` found at: #{elixir_exe}")
120+
env = [
121+
{~c"LSP", ~c"nextls"},
122+
{~c"NEXTLS_PARENT_PID", parent},
123+
{~c"MIX_ENV", ~c"#{mix_env}"},
124+
{~c"MIX_TARGET", ~c"#{mix_target}"},
125+
{~c"MIX_BUILD_ROOT", ~c".elixir-tools/_build"},
126+
{~c"ROOTDIR", false},
127+
{~c"BINDIR", false},
128+
{~c"RELEASE_ROOT", false},
129+
{~c"RELEASE_SYS_CONFIG", false},
130+
{~c"PATH", String.to_charlist(new_path)}
131+
]
132+
133+
args =
134+
[elixir_exe] ++
135+
if @env == :test do
136+
["--erl", "-kernel prevent_overlapping_partitions false"]
137+
else
138+
[]
139+
end ++
140+
[
141+
"--no-halt",
142+
"--sname",
143+
sname,
144+
"--cookie",
145+
Node.get_cookie(),
146+
"-S",
147+
"mix",
148+
"loadpaths",
149+
"--no-compile"
150+
]
151+
152+
NextLS.Logger.info(logger, """
153+
Booting runtime for #{name}.
154+
155+
- elixir: #{elixir_exe}
156+
- zombie wrapper script: #{exe}
157+
- working_dir: #{working_dir}
158+
- command: #{Enum.join(args, " ")}
159+
160+
Environment:
161+
162+
#{Enum.map_join(env, "\n", fn {k, v} -> "#{k}=#{v}" end)}
163+
""")
121164

122165
port =
123166
Port.open(
@@ -128,36 +171,8 @@ defmodule NextLS.Runtime do
128171
:binary,
129172
:stream,
130173
cd: working_dir,
131-
env: [
132-
{~c"LSP", ~c"nextls"},
133-
{~c"NEXTLS_PARENT_PID", parent},
134-
{~c"MIX_ENV", ~c"#{mix_env}"},
135-
{~c"MIX_TARGET", ~c"#{mix_target}"},
136-
{~c"MIX_BUILD_ROOT", ~c".elixir-tools/_build"},
137-
{~c"ROOTDIR", false},
138-
{~c"BINDIR", false},
139-
{~c"RELEASE_ROOT", false},
140-
{~c"RELEASE_SYS_CONFIG", false},
141-
{~c"PATH", String.to_charlist(new_path)}
142-
],
143-
args:
144-
[elixir_exe] ++
145-
if @env == :test do
146-
["--erl", "-kernel prevent_overlapping_partitions false"]
147-
else
148-
[]
149-
end ++
150-
[
151-
"--no-halt",
152-
"--sname",
153-
sname,
154-
"--cookie",
155-
Node.get_cookie(),
156-
"-S",
157-
"mix",
158-
"loadpaths",
159-
"--no-compile"
160-
]
174+
env: env,
175+
args: args
161176
]
162177
)
163178

0 commit comments

Comments
 (0)