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

bugfixes and improvements (ipfs daemon flags) #107

Merged
merged 9 commits into from
Sep 16, 2016
Merged

Conversation

jbenet
Copy link
Member

@jbenet jbenet commented Sep 16, 2016

d74045f (jbenet, 2 minutes ago)
feat(startDeamon): allow passing flags to ipfs daemon

9c4dbce (jbenet, 4 minutes ago)
fix(startDaemon): fix the behavior of startDeamon

- now waits for "Daemon is ready"
- also tracks Gateway address
- checks failures on startup, and returns an error if so
 - this was a serious bug-- would not detect errors.
- fails correctly, without leaving the process hanging

b523b1c (jbenet, 7 minutes ago)
fix: rm unused var (thanks, linter)

efa2aa4 (jbenet, 10 minutes ago)
note(shutdown): comment on problematic func name

d6ad480 (jbenet, 14 minutes ago)
fix(shutdown): fixed bugs in stopDaemon

- bug1: local var for the closure (this.subprocess set to null)
- bug2: order problem: should set .on('close') handler before .kill()

3c50894 (jbenet, 17 minutes ago)
fix(tests): don't force changing test when src changes

- bug1: local var for the closure (this.subprocess set to null)
- bug2: order problem: should set .on('close') handler before .kill()
- now waits for "Daemon is ready"
- also tracks Gateway address
- checks failures on startup, and returns an error if so
  - this was a serious bug-- would not detect errors.
- fails correctly, without leaving the process hanging
@@ -44,7 +44,7 @@
"license": "MIT",
"dependencies": {
"go-ipfs-dep": "0.4.1",
"ipfs-api": "^4.1.0",
"ipfs-api": "^9.0.0",
Copy link
Member

Choose a reason for hiding this comment

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

🌟

@@ -109,6 +106,8 @@ module.exports = class Node {
}

// cleanup tmp files
// TODO: this is a bad name for a function. a user may call this expecting
// something similar to "stopDaemon()". consider changing it. - @jbenet
Copy link
Member

Choose a reason for hiding this comment

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

👍

const apiM = stdout.match(/API server listening on (.*)\n/)
if (apiM) {
// found the API server listening. extract the addr.
node.apiAddr = apiM[1]
Copy link
Member

Choose a reason for hiding this comment

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

This is a bit ninja. the daemon leaves a 'api' file on the repo with the multiaddr that is listening. It would be more safe to use that than trusting that this string will be always the same.

Copy link
Member Author

Choose a reason for hiding this comment

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

this was the way it was. i did not change it

Copy link
Member

Choose a reason for hiding this comment

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

ACK. Opened a issue so that it doesn't get lost - #108

const api = ipfs(node.apiAddr)
api.apiHost = addr.address
api.apiPort = addr.port
done2(null, api)
Copy link
Member

Choose a reason for hiding this comment

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

The js-ipfs-api is able to dial to multiaddrs, no need for parsing. It is a good practice to keep using multiaddrs for addrs everywhere

Copy link
Member Author

Choose a reason for hiding this comment

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

this would change the expected api-- i dont necessarily want to break things expecting this to be here

Copy link
Member

Choose a reason for hiding this comment

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

👍

node.killProcess(() => {}) // we failed. kill, just to be sure...
}
done(err, val)
done = () => {} // in case it gets called twice
Copy link
Member

Choose a reason for hiding this comment

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

If we get multiple errors (queued) do we want to do node.killProcess several times? What about having a flag 'isDead'?

Copy link
Member Author

Choose a reason for hiding this comment

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

okay sounds good

@@ -118,51 +117,106 @@ module.exports = class Node {
}
}

startDaemon (done) {
parseConfig(this.path, (err, conf) => {
startDaemon (flags, done) {
Copy link
Member

Choose a reason for hiding this comment

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

callbacks at the top level of the func should be callback just to keep being consistent with the rest of js ecosystem (I do notice that applies to other parts of this module, it just means it was never refactored)

Copy link
Member Author

@jbenet jbenet Sep 16, 2016

Choose a reason for hiding this comment

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

yeah i dont want to change this across whole module, that could be a separate PR

.on('data', onData)

// done2 is called to call done after removing the event listeners
function done2 (err, val) {
Copy link
Member

Choose a reason for hiding this comment

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

This doesn't seem right. This function gets called on a successful start of a node or a on insuccessful one. Can we have instead a 'failure' func and a 'success' func instead?

Copy link
Member Author

Choose a reason for hiding this comment

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

in both cases the same thing -- removing listeners -- has to happen, you would have two functions with the same code. this changes from the old behavior (which was just to call done, to this wrapper on done (done2, not the best name))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants