Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
G
go-ipfs
概览
概览
详情
活动
周期分析
版本库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程表
图表
维基
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
jihao
go-ipfs
Commits
d0380b73
提交
d0380b73
authored
9月 27, 2014
作者:
Juan Batiz-Benet
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
const for lock file, + fix unreachable Close
上级
508a5b7a
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
16 行增加
和
9 行删除
+16
-9
daemon.go
daemon/daemon.go
+10
-2
daemon_client.go
daemon/daemon_client.go
+6
-7
没有找到文件。
daemon/daemon.go
浏览文件 @
d0380b73
...
...
@@ -6,11 +6,12 @@ import (
"io"
"net"
"os"
"path"
core
"github.com/jbenet/go-ipfs/core"
"github.com/jbenet/go-ipfs/core/commands"
u
"github.com/jbenet/go-ipfs/util"
"github.com/op/go-logging"
logging
"github.com/op/go-logging"
"github.com/camlistore/lock"
ma
"github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-multiaddr"
...
...
@@ -18,6 +19,9 @@ import (
var
log
=
logging
.
MustGetLogger
(
"daemon"
)
// LockFile is the filename of the daemon lock, relative to config dir
const
LockFile
=
"daemon.lock"
// DaemonListener listens to an initialized IPFS node and can send it commands instead of
// starting up a new set of connections
type
DaemonListener
struct
{
...
...
@@ -41,7 +45,7 @@ func NewDaemonListener(ipfsnode *core.IpfsNode, addr *ma.Multiaddr, confdir stri
return
nil
,
err
}
lk
,
err
:=
lock
.
Lock
(
confdir
+
"/daemon.lock"
)
lk
,
err
:=
daemonLock
(
confdir
)
if
err
!=
nil
{
return
nil
,
err
}
...
...
@@ -133,3 +137,7 @@ func (dl *DaemonListener) Close() error {
dl
.
closed
=
true
return
dl
.
list
.
Close
()
}
func
daemonLock
(
confdir
string
)
(
io
.
Closer
,
error
)
{
return
lock
.
Lock
(
path
.
Join
(
confdir
,
LockFile
))
}
daemon/daemon_client.go
浏览文件 @
d0380b73
...
...
@@ -8,7 +8,6 @@ import (
"net"
"os"
lock
"github.com/camlistore/lock"
ma
"github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-multiaddr"
u
"github.com/jbenet/go-ipfs/util"
...
...
@@ -43,10 +42,10 @@ func getDaemonAddr(confdir string) (string, error) {
return
string
(
line
),
nil
}
// SendCommand
issues a command (of type daemon.Command) to the daemon, if it
//
is running (if not, errors out). This is done over network RPC API. Th
e
//
address of the daemon is retrieved from the configuration directory, where
// live daemons write their addresses to special files.
// SendCommand
attempts to run the command over a currently-running daemon.
//
If there is no running daemon, returns ErrDaemonNotRunning. This is don
e
//
over network RPC API. The address of the daemon is retrieved from the config
//
directory, where
live daemons write their addresses to special files.
func
SendCommand
(
command
*
Command
,
confdir
string
)
error
{
//check if daemon is running
log
.
Info
(
"Checking if daemon is running..."
)
...
...
@@ -55,10 +54,10 @@ func SendCommand(command *Command, confdir string) error {
if
err
!=
nil
{
return
err
}
lk
,
err
:=
lock
.
Lock
(
confdir
+
"/daemon.lock"
)
lk
,
err
:=
daemonLock
(
confdir
)
if
err
==
nil
{
return
ErrDaemonNotRunning
lk
.
Close
()
return
ErrDaemonNotRunning
}
log
.
Info
(
"Daemon is running! %s"
,
err
)
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论