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

Graceful shutdown #12

Open
burdiyan opened this issue Mar 26, 2020 · 5 comments
Open

Graceful shutdown #12

burdiyan opened this issue Mar 26, 2020 · 5 comments

Comments

@burdiyan
Copy link

burdiyan commented Mar 26, 2020

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 explicit Start method that would block and could accept a context for being canceled.

@hsanjuan
Copy link
Owner

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?

Yes, probably better. Do you have a situation where this matters or generates a problem?

@burdiyan
Copy link
Author

Not really. I'm just a bit of a graceful shutdown freak to be honest :)

@hsanjuan
Copy link
Owner

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.

@burdiyan
Copy link
Author

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?

@hsanjuan
Copy link
Owner

AutoClose can be an option enabled by default, and the Close method added additionally.

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

No branches or pull requests

2 participants