Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
彭彦祖
code-server
提交
cf0f1110
C
code-server
项目概览
彭彦祖
/
code-server
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
C
code-server
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
未验证
提交
cf0f1110
编写于
2月 21, 2020
作者:
A
Asher
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Handle upgrade from binary to loose files
As best we can, anyway.
上级
9b7a203f
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
29 addition
and
14 deletion
+29
-14
src/node/wrapper.ts
src/node/wrapper.ts
+29
-14
未找到文件。
src/node/wrapper.ts
浏览文件 @
cf0f1110
import
{
logger
,
field
}
from
"
@coder/logger
"
import
*
as
cp
from
"
child_process
"
import
*
as
fs
from
"
fs-extra
"
import
*
as
path
from
"
path
"
import
{
Emitter
}
from
"
../common/emitter
"
interface
HandshakeMessage
{
...
...
@@ -175,40 +177,53 @@ export class WrapperProcess {
public
start
():
Promise
<
void
>
{
if
(
!
this
.
started
)
{
const
child
=
this
.
spawn
()
logger
.
debug
(
`spawned inner process
${
child
.
pid
}
`
)
this
.
started
=
ipcMain
()
.
handshake
(
child
)
.
then
(()
=>
{
child
.
once
(
"
exit
"
,
(
code
)
=>
{
logger
.
debug
(
`inner process
${
child
.
pid
}
exited unexpectedly`
)
ipcMain
().
exit
(
code
||
0
)
this
.
started
=
this
.
spawn
().
then
((
child
)
=>
{
logger
.
debug
(
`spawned inner process
${
child
.
pid
}
`
)
ipcMain
()
.
handshake
(
child
)
.
then
(()
=>
{
child
.
once
(
"
exit
"
,
(
code
)
=>
{
logger
.
debug
(
`inner process
${
child
.
pid
}
exited unexpectedly`
)
ipcMain
().
exit
(
code
||
0
)
})
})
})
this
.
process
=
child
this
.
process
=
child
})
}
return
this
.
started
}
private
spawn
():
cp
.
ChildProcess
{
private
async
spawn
():
Promise
<
cp
.
ChildProcess
>
{
// Flags to pass along to the Node binary.
let
nodeOptions
=
`
${
process
.
env
.
NODE_OPTIONS
||
""
}
${(
this
.
options
&&
this
.
options
.
nodeOptions
)
||
""
}
`
if
(
!
/max_old_space_size=
(\d
+
)
/g
.
exec
(
nodeOptions
))
{
nodeOptions
+=
` --max_old_space_size=
${(
this
.
options
&&
this
.
options
.
maxMemory
)
||
2048
}
`
}
return
cp
.
fork
(
process
.
argv
[
1
],
process
.
argv
.
slice
(
2
),
{
// This is to handle the upgrade from binary release to loose release. This
// will only work for users that restart code-server entirely between
// upgrading to this version and the loose file version since this is the
// wrapper code that does not get updated. The hope is that it'll be likely
// for that to happen to most users in that timeframe to minimize disruption
// when loose files are release. This can be removed with that release.
const
bundledNodePath
=
path
.
join
(
process
.
argv
[
0
],
"
node
"
)
const
binary
=
(
await
fs
.
pathExists
(
bundledNodePath
))
?
bundledNodePath
:
process
.
argv
[
0
]
// Use spawn (instead of fork) to use the new binary in case it was updated.
return
cp
.
spawn
(
binary
,
process
.
argv
.
slice
(
1
),
{
env
:
{
...
process
.
env
,
CODE_SERVER_PARENT_PID
:
process
.
pid
.
toString
(),
NODE_OPTIONS
:
nodeOptions
,
NBIN_BYPASS
:
undefined
,
},
stdio
:
[
"
inherit
"
,
"
inherit
"
,
"
inherit
"
,
"
ipc
"
],
})
}
}
//
//
It's possible that the pipe has closed (for example if you run code-server
//
//
--version | head -1). Assume that means we're done.
// It's possible that the pipe has closed (for example if you run code-server
// --version | head -1). Assume that means we're done.
if
(
!
process
.
stdout
.
isTTY
)
{
process
.
stdout
.
on
(
"
error
"
,
()
=>
ipcMain
().
exit
())
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录