Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(daemon) ipfs daemon --initialized #355

Merged
merged 27 commits into from
Nov 18, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
5fa31f8
deps(go-datastore) update
Nov 17, 2014
cf8fb87
refactor(errors) debugerror -> errors
Nov 16, 2014
11fd2aa
feat(util) FileExists
Nov 16, 2014
356a2d7
fix(daemon) if lock file does not exist, then the lock is not acquired
Nov 16, 2014
884d629
deps(eventlog) no need to augment Logger
Nov 16, 2014
ddb0189
refactor(eventlog) use polite formatter as a direct dependency
Nov 16, 2014
f26388e
fix(core) tear-down leveldb
Nov 16, 2014
bacf3ec
feat(util) add datastore Closer Wrapper
Nov 17, 2014
aba4b2b
feat(eventlog) initialize event logger with silent defaults
Nov 16, 2014
81f5d6f
debug(2/ipfs) make cmdDetails loggable
Nov 16, 2014
c883f7d
refactor(2/init) extract const
Nov 16, 2014
6a380ff
refactor(2/init) use util.FileExists
Nov 16, 2014
d0a3f9b
feat(2/init) expose init with defaults
Nov 16, 2014
2bbfe4d
debug(core, datastore, daemon) wrap errors
Nov 16, 2014
0612004
feat(2/daemon) --initialized
Nov 16, 2014
94bfc81
docs(eventlog/formatter)
Nov 17, 2014
bc39661
fix(2/daemon) initialized --> init
Nov 17, 2014
ef65bb1
revert to debug error
Nov 17, 2014
84354c7
doc(eventlog) init
Nov 17, 2014
cc02471
docs(Dockerfile) update docker 'run' example
Nov 18, 2014
24f0fa0
delegate teardown
Nov 18, 2014
7cebc3c
inline prints
Nov 18, 2014
8d4c216
fix
Nov 18, 2014
493e5d3
test: test init output
jbenet Nov 18, 2014
088016c
test: cat test actual output
jbenet Nov 18, 2014
d93e49e
fix node context (tests pass)
jbenet Nov 18, 2014
eba0599
bugfix: node teardown is the last man to go down
jbenet Nov 18, 2014
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ ENTRYPOINT ["ipfs"]
CMD ["run"]

# build: docker build -t go-ipfs .
# run: docker run -p 4001:4001 -e "IPFS_LOGGING=debug" go-ipfs:latest run
# run: docker run -p 4001:4001 -p 5001:5001 go-ipfs:latest daemon --init
6 changes: 3 additions & 3 deletions Godeps/Godeps.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 0 additions & 19 deletions Godeps/_workspace/src/github.com/jbenet/go-datastore/query.go

This file was deleted.

11 changes: 3 additions & 8 deletions Godeps/_workspace/src/github.com/maybebtc/logrus/entry.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 0 additions & 5 deletions Godeps/_workspace/src/github.com/maybebtc/logrus/logger.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

34 changes: 30 additions & 4 deletions cmd/ipfs2/daemon.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,20 @@ import (
"fmt"
"net/http"

manners "github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/braintree/manners"
ma "github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-multiaddr"
manet "github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-multiaddr/net"

manners "github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/braintree/manners"
cmds "github.com/jbenet/go-ipfs/commands"
cmdsHttp "github.com/jbenet/go-ipfs/commands/http"
core "github.com/jbenet/go-ipfs/core"
commands "github.com/jbenet/go-ipfs/core/commands2"
daemon "github.com/jbenet/go-ipfs/daemon2"
util "github.com/jbenet/go-ipfs/util"
"github.com/jbenet/go-ipfs/util/debugerror"
)

const (
initOptionKwd = "init"
)

var daemonCmd = &cmds.Command{
Expand All @@ -27,15 +32,36 @@ the daemon.
`,
},

Options: []cmds.Option{},
Options: []cmds.Option{
cmds.BoolOption(initOptionKwd, "Initialize IPFS with default settings if not already initialized"),
},
Subcommands: map[string]*cmds.Command{},
Run: daemonFunc,
}

func daemonFunc(req cmds.Request) (interface{}, error) {

initialize, _, err := req.Option(initOptionKwd).Bool()
if err != nil {
return nil, err
}
if initialize {

// now, FileExists is our best method of detecting whether IPFS is
// configured. Consider moving this into a config helper method
// `IsInitialized` where the quality of the signal can be improved over
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

completely agree. thank you for this note.

// time, and many call-sites can benefit.
if !util.FileExists(req.Context().ConfigRoot) {
err := initWithDefaults(req.Context().ConfigRoot)
if err != nil {
return nil, debugerror.Wrap(err)
}
}
}

lock, err := daemon.Lock(req.Context().ConfigRoot)
if err != nil {
return nil, fmt.Errorf("Couldn't obtain lock. Is another daemon already running?")
return nil, debugerror.Errorf("Couldn't obtain lock. Is another daemon already running?")
}
defer lock.Close()

Expand Down
Loading