Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
G
go-ipfs
概览
概览
详情
活动
周期分析
版本库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程表
图表
维基
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
jihao
go-ipfs
Commits
7cfb4aa2
提交
7cfb4aa2
authored
5月 25, 2019
作者:
Łukasz Magiera
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
core: call app.Stop once
上级
2192ed77
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
14 行增加
和
8 行删除
+14
-8
builder.go
core/builder.go
+12
-4
core.go
core/core.go
+2
-4
没有找到文件。
core/builder.go
浏览文件 @
7cfb4aa2
...
...
@@ -2,6 +2,7 @@ package core
import
(
"context"
"sync"
"github.com/ipfs/go-metrics-interface"
"go.uber.org/fx"
...
...
@@ -27,19 +28,26 @@ func NewNode(ctx context.Context, cfg *BuildCfg) (*IpfsNode, error) {
fx
.
Extract
(
n
),
)
var
once
sync
.
Once
var
stopErr
error
n
.
stop
=
func
()
error
{
once
.
Do
(
func
()
{
stopErr
=
app
.
Stop
(
context
.
Background
())
})
return
stopErr
}
n
.
IsOnline
=
cfg
.
Online
go
func
()
{
// Note that some services use contexts to signal shutting down, which is
// very suboptimal. This needs to be here until that's addressed somehow
<-
ctx
.
Done
()
err
:=
app
.
Stop
(
context
.
Background
()
)
err
:=
n
.
stop
(
)
if
err
!=
nil
{
log
.
Error
(
"failure on stop: "
,
err
)
}
}()
n
.
IsOnline
=
cfg
.
Online
n
.
app
=
app
if
app
.
Err
()
!=
nil
{
return
nil
,
app
.
Err
()
}
...
...
core/core.go
浏览文件 @
7cfb4aa2
...
...
@@ -13,8 +13,6 @@ import (
"context"
"io"
"go.uber.org/fx"
version
"github.com/ipfs/go-ipfs"
"github.com/ipfs/go-ipfs/core/bootstrap"
"github.com/ipfs/go-ipfs/core/node"
...
...
@@ -107,7 +105,7 @@ type IpfsNode struct {
Process
goprocess
.
Process
ctx
context
.
Context
app
*
fx
.
App
stop
func
()
error
// Flags
IsOnline
bool
`optional:"true"`
// Online is set when networking is enabled.
...
...
@@ -124,7 +122,7 @@ type Mounts struct {
// Close calls Close() on the App object
func
(
n
*
IpfsNode
)
Close
()
error
{
return
n
.
app
.
Stop
(
n
.
ctx
)
return
n
.
stop
(
)
}
// Context returns the IpfsNode context
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论