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
1bac12f9
Commit
1bac12f9
authored
Apr 21, 2015
by
Juan Batiz-Benet
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1103 from travisperson/bug/init-with-daemon
Check to see if the daemon is currently running
parents
33fab229
676fd50c
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
23 additions
and
0 deletions
+23
-0
cmd/ipfs/init.go
cmd/ipfs/init.go
+11
-0
test/sharness/t0020-init.sh
test/sharness/t0020-init.sh
+12
-0
No files found.
cmd/ipfs/init.go
View file @
1bac12f9
...
...
@@ -35,6 +35,17 @@ var initCmd = &cmds.Command{
// name of the file?
// TODO cmds.StringOption("event-logs", "l", "Location for machine-readable event logs"),
},
PreRun
:
func
(
req
cmds
.
Request
)
error
{
daemonLocked
:=
fsrepo
.
LockedByOtherProcess
(
req
.
Context
()
.
ConfigRoot
)
log
.
Info
(
"checking if daemon is running..."
)
if
daemonLocked
{
e
:=
"ipfs daemon is running. please stop it to run this command"
return
cmds
.
ClientError
(
e
)
}
return
nil
},
Run
:
func
(
req
cmds
.
Request
,
res
cmds
.
Response
)
{
force
,
_
,
err
:=
req
.
Option
(
"f"
)
.
Bool
()
// if !found, it's okay force == false
...
...
test/sharness/t0020-init.sh
View file @
1bac12f9
...
...
@@ -44,4 +44,16 @@ test_expect_success "ipfs init output looks good" '
test_cmp expected actual_init
'
test_init_ipfs
test_launch_ipfs_daemon
test_expect_success
"ipfs init should not run while daemon is running"
'
test_must_fail ipfs init 2> daemon_running_err &&
EXPECT="Error: ipfs daemon is running. please stop it to run this command" &&
grep "$EXPECT" daemon_running_err
'
test_kill_ipfs_daemon
test_done
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