Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
dms3
go-dms3
Commits
3ab3170a
Commit
3ab3170a
authored
Oct 18, 2014
by
Jeromy
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
IPFS_ADDRESS_RPC env var for changing rpc target
parent
f2e428d4
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
28 additions
and
11 deletions
+28
-11
daemon/daemon_client.go
daemon/daemon_client.go
+28
-11
No files found.
daemon/daemon_client.go
View file @
3ab3170a
...
...
@@ -47,26 +47,43 @@ func getDaemonAddr(confdir string) (string, error) {
// 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..."
)
server
:=
os
.
Getenv
(
"IPFS_ADDRESS_RPC"
)
if
server
==
""
{
//check if daemon is running
log
.
Info
(
"Checking if daemon is running..."
)
if
!
serverIsRunning
(
confdir
)
{
return
ErrDaemonNotRunning
}
log
.
Info
(
"Daemon is running!"
)
var
err
error
server
,
err
=
getDaemonAddr
(
confdir
)
if
err
!=
nil
{
return
err
}
}
return
serverComm
(
server
,
command
)
}
func
serverIsRunning
(
confdir
string
)
bool
{
var
err
error
confdir
,
err
=
u
.
TildeExpansion
(
confdir
)
if
err
!=
nil
{
return
err
log
.
Error
(
"Tilde Expansion Failed: %s"
,
err
)
return
false
}
lk
,
err
:=
daemonLock
(
confdir
)
if
err
==
nil
{
lk
.
Close
()
return
ErrDaemonNotRunning
}
log
.
Info
(
"Daemon is running! [reason = %s]"
,
err
)
server
,
err
:=
getDaemonAddr
(
confdir
)
if
err
!=
nil
{
return
err
return
false
}
return
true
}
func
serverComm
(
server
string
,
command
*
Command
)
error
{
log
.
Info
(
"Daemon address: %s"
,
server
)
maddr
,
err
:=
ma
.
NewMultiaddr
(
server
)
if
err
!=
nil
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment