Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
G
go-ipfs
概览
概览
详情
活动
周期分析
版本库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程表
图表
维基
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
jihao
go-ipfs
Commits
c3722558
提交
c3722558
authored
2月 01, 2015
作者:
Juan Batiz-Benet
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
daemon: fix output + time waiting
上级
282be4fd
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
25 行增加
和
21 行删除
+25
-21
daemon.go
cmd/ipfs/daemon.go
+9
-11
test-lib.sh
test/sharness/lib/test-lib.sh
+16
-10
没有找到文件。
cmd/ipfs/daemon.go
浏览文件 @
c3722558
package
main
import
(
"bytes"
"fmt"
"os"
ma
"github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-multiaddr"
cmds
"github.com/jbenet/go-ipfs/commands"
...
...
@@ -51,9 +51,8 @@ the daemon.
}
func
daemonFunc
(
req
cmds
.
Request
,
res
cmds
.
Response
)
{
var
out
bytes
.
Buffer
res
.
SetOutput
(
&
out
)
writef
(
&
out
,
"Initializing daemon...
\n
"
)
// let the user know we're going.
fmt
.
Printf
(
"Initializing daemon...
\n
"
)
// first, whether user has provided the initialization flag. we may be
// running in an uninitialized state.
...
...
@@ -70,7 +69,7 @@ func daemonFunc(req cmds.Request, res cmds.Response) {
// `IsInitialized` where the quality of the signal can be improved over
// time, and many call-sites can benefit.
if
!
util
.
FileExists
(
req
.
Context
()
.
ConfigRoot
)
{
err
:=
initWithDefaults
(
&
out
,
req
.
Context
()
.
ConfigRoot
)
err
:=
initWithDefaults
(
os
.
Std
out
,
req
.
Context
()
.
ConfigRoot
)
if
err
!=
nil
{
res
.
SetError
(
debugerror
.
Wrap
(
err
),
cmds
.
ErrNormal
)
return
...
...
@@ -155,8 +154,8 @@ func daemonFunc(req cmds.Request, res cmds.Response) {
res
.
SetError
(
err
,
cmds
.
ErrNormal
)
return
}
writef
(
&
out
,
"IPFS mounted at: %s
\n
"
,
fsdir
)
writef
(
&
out
,
"IPNS mounted at: %s
\n
"
,
nsdir
)
fmt
.
Printf
(
"IPFS mounted at: %s
\n
"
,
fsdir
)
fmt
.
Printf
(
"IPNS mounted at: %s
\n
"
,
nsdir
)
}
var
rootRedirect
corehttp
.
ServeOption
...
...
@@ -173,10 +172,6 @@ func daemonFunc(req cmds.Request, res cmds.Response) {
writable
=
cfg
.
Gateway
.
Writable
}
if
writable
{
fmt
.
Printf
(
"IPNS gateway mounted read-write
\n
"
)
}
if
gatewayMaddr
!=
nil
{
go
func
()
{
var
opts
=
[]
corehttp
.
ServeOption
{
corehttp
.
GatewayOption
(
writable
)}
...
...
@@ -184,6 +179,9 @@ func daemonFunc(req cmds.Request, res cmds.Response) {
opts
=
append
(
opts
,
rootRedirect
)
}
fmt
.
Printf
(
"Gateway server listening on %s
\n
"
,
gatewayMaddr
)
if
writable
{
fmt
.
Printf
(
"Gateway server is writable
\n
"
)
}
err
:=
corehttp
.
ListenAndServe
(
node
,
gatewayMaddr
.
String
(),
opts
...
)
if
err
!=
nil
{
log
.
Error
(
err
)
...
...
test/sharness/lib/test-lib.sh
浏览文件 @
c3722558
...
...
@@ -74,15 +74,16 @@ test_run_repeat_10_sec() {
}
test_wait_output_n_lines_60_sec
()
{
echo
"
$2
"
>
expected_waitn
for
i
in
1 2 3 4 5 6 7 8 9 10
for
i
in
1 2 3 4 5 6
do
cat
"
$1
"
| wc
-l
| tr
-d
" "
>
actual_waitn
test_cmp
"expected_waitn"
"actual_waitn"
&&
return
sleep 2
for
i
in
1 2 3 4 5 6 7 8 9 10
do
test
$(
cat
"
$1
"
| wc
-l
| tr
-d
" "
)
-ge
$2
&&
return
sleep 1
done
done
cat
"
$1
"
| wc
-l
| tr
-d
" "
>
actual_waitn
test_cmp
"expected_waitn"
"actual_waitn
"
actual
=
$(
cat
"
$1
"
| wc
-l
| tr
-d
" "
)
fsh
"expected
$2
lines of output. got
$actual
"
}
test_wait_open_tcp_port_10_sec
()
{
...
...
@@ -130,6 +131,13 @@ test_config_ipfs_gateway_writable() {
test_launch_ipfs_daemon
()
{
ADDR_API
=
"/ip4/127.0.0.1/tcp/5001"
ADDR_GWAY
=
`
ipfs config Addresses.Gateway
`
NLINES
=
"2"
if
test
"
$ADDR_GWAY
"
!=
""
;
then
NLINES
=
"3"
fi
test_expect_success
"'ipfs daemon' succeeds"
'
ipfs daemon >actual_daemon 2>daemon_err &
'
...
...
@@ -138,19 +146,17 @@ test_launch_ipfs_daemon() {
# and we make sure there are no errors
test_expect_success
"'ipfs daemon' is ready"
'
IPFS_PID=$! &&
test_
run_repeat_10_sec "cat actual_daemon | grep \"API server listening on\""
&&
test_
wait_output_n_lines_60_sec actual_daemon $NLINES
&&
printf "" >empty && test_cmp daemon_err empty ||
fsh cat actual_daemon || fsh cat daemon_err
'
ADDR_API
=
"/ip4/127.0.0.1/tcp/5001"
test_expect_success
"'ipfs daemon' output includes API address"
'
cat actual_daemon | grep "API server listening on $ADDR_API" ||
fsh cat actual_daemon ||
fsh "cat actual_daemon | grep \"API server listening on $ADDR_API\""
'
ADDR_GWAY
=
`
ipfs config Addresses.Gateway
`
if
test
"
$ADDR_GWAY
"
!=
""
;
then
test_expect_success
"'ipfs daemon' output includes Gateway address"
'
cat actual_daemon | grep "Gateway server listening on $ADDR_GWAY" ||
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论