Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitc180d50

Browse files
committed
Update pid
1 parent639911b commitc180d50

File tree

1 file changed

+37
-23
lines changed

1 file changed

+37
-23
lines changed

‎src/remote.ts

Lines changed: 37 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -274,55 +274,69 @@ export class Remote {
274274
// We can ignore this, it's probably blank!
275275
}
276276
})
277+
letremotePID=0
277278
// Store the running port for the current commit in a file for reconnection!
278-
constportFilePath=`/tmp/.vscode-remote-${this.vscodeCommit}-port`
279+
constportFilePath=(pid=remotePID)=>{
280+
return`/tmp/.vscode-remote-${pid}`
281+
}
282+
constfiltered=running.filter((instance)=>instance.commit===this.vscodeCommit)
283+
if(filtered.length){
284+
remotePID=filtered[0].process_id
285+
awaitthis.ipc.execute(shell,`cat${portFilePath(remotePID)}`,(data)=>{
286+
if(data.trim()){
287+
remotePort=Number.parseInt(data.trim())
288+
}
289+
})
290+
}
291+
279292
letremotePort=0
280293
if(running.filter((instance)=>instance.commit===this.vscodeCommit)){
281294
awaitthis.ipc.execute(shell,`cat${portFilePath}`,(data)=>{
282295
if(data.trim()){
283296
remotePort=Number.parseInt(data.trim())
284297
}
285298
})
286-
287-
this.output.appendLine("Found existing server running on port: "+remotePort)
299+
if(remotePort){
300+
this.output.appendLine("Found existing server running on port: "+remotePort)
301+
}
288302
}
289303

290304
if(!remotePort){
291305
remotePort=awaitnewPromise<number>((resolve,reject)=>{
292-
constscript=
293-
binPath+
294-
" serve-local --start-server --port 0 --without-connection-token --commit-id "+
295-
this.vscodeCommit+
296-
" --accept-server-license-terms"
306+
constscript=`
307+
${binPath} serve-local --start-server --port 0 --without-connection-token --commit-id${this.vscodeCommit} --accept-server-license-terms &
308+
echo "PID: $!"
309+
wait
310+
`
311+
297312
this.ipc
298313
?.execute(shell,script,(data)=>{
299314
constlines=data.split("\n")
300315
lines.forEach((line)=>{
301316
this.output.appendLine(line)
302-
if(!line.startsWith("Server bound to")){
303-
return
304-
}
305-
constparts=line.split(" ").filter((part)=>part.startsWith("127.0.0.1:"))
306-
if(parts.length===0){
307-
returnreject("No port found in output: "+line)
317+
if(line.startsWith("PID: ")){
318+
console.log("WE GOT PID",line)
319+
remotePID=Number.parseInt(line.split("PID: ")[1].trim())
308320
}
309-
constport=parts[0].split(":").pop()
310-
if(!port){
311-
returnreject("No port found in parts: "+parts.join(","))
321+
if(line.startsWith("Server bound to")){
322+
constparts=line.split(" ").filter((part)=>part.startsWith("127.0.0.1:"))
323+
if(parts.length===0){
324+
returnreject("No port found in output: "+line)
325+
}
326+
constport=parts[0].split(":").pop()
327+
if(!port){
328+
returnreject("No port found in parts: "+parts.join(","))
329+
}
330+
resolve(Number.parseInt(port))
312331
}
313-
resolve(Number.parseInt(port))
314332
})
315333
})
316334
.then((exitCode)=>{
317335
reject("Exited with: "+exitCode)
318336
})
319337
})
320338

321-
awaitthis.ipc.execute(
322-
shell,
323-
`echo${remotePort} > /tmp/.vscode-remote-${this.vscodeCommit}-port`,
324-
()=>undefined,
325-
)
339+
awaitthis.ipc.execute(shell,`echo${remotePort} >${portFilePath(remotePID)}`,()=>undefined)
326340
}
327341

328342
constforwarded=awaitthis.ipc.portForward(remotePort)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp