-
Notifications
You must be signed in to change notification settings - Fork 58
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
Graceful shutdown #12
Comments
Yes, probably better. Do you have a situation where this matters or generates a problem? |
Not really. I'm just a bit of a graceful shutdown freak to be honest :) |
I'll keep this open. Things do break sometimes because of this, and I think go-ipfs has issues with the reprovider being closed after the datastore and things like that. |
I'd submit a PR, but probably you'd have to cut a v2 release for this change since it wouldn't be backward compatible. Unless we add an explicit Close method that would wait until autoclose goroutine returns. WDYT? |
AutoClose can be an option enabled by default, and the Close method added additionally. |
I was looking at the code and something caught my attention. I see that instantiating a peer would spin up a goroutine that would wait on the context.Done channel and then close some of the underlying dependencies.
https://github.com/hsanjuan/ipfs-lite/blob/master/ipfs.go#L128
I might be wrong, but it seems like there's no way to wait until this shutdown process is actually finished. The
autoclose
goroutine is not signaling anywhere when it's done.Wouldn't it be more correct to provide explicit
Close
method so that users of ipfs-lite could chose to wait until the peer is actually closed? Another approach could be providing an explicitStart
method that would block and could accept a context for being canceled.The text was updated successfully, but these errors were encountered: