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

Add graceful shutdown #386

Closed
bahlo opened this issue Oct 22, 2021 · 9 comments
Closed

Add graceful shutdown #386

bahlo opened this issue Oct 22, 2021 · 9 comments

Comments

@bahlo
Copy link

bahlo commented Oct 22, 2021

Would be great to get graceful shutdown. Right now I'm tokio::select!ing on the future of libunftp::Server.listen and my shutdown future, a.k.a just dropping the everything which isn't great.

@hannesdejager
Copy link
Collaborator

Thanks @bahlo . Agreed.

Is there any specific interface you're looking for?

@bahlo
Copy link
Author

bahlo commented Oct 22, 2021

@hannesdejager Yes, similar to the hyper::Server one.

See also Graceful Shutdown.

hannesdejager added a commit that referenced this issue Oct 30, 2021
hannesdejager added a commit that referenced this issue Nov 12, 2021
hannesdejager added a commit that referenced this issue Nov 12, 2021
@hannesdejager
Copy link
Collaborator

@bahlo I'm adding a Server::shutdown_indicator method:

image

Usage will look something like this:

    let mut server = Server::with_authenticator(storage_backend, Arc::new(authenticator))
        .greeting("Welcome to unFTP")
        .passive_ports(start_port..end_port)
        .idle_session_timeout(idle_timeout)
        .logger(root_log.new(o!("lib" => "libunftp")))
        .passive_host(passive_host)
        .sitemd5(md5_setting)
        .shutdown_indicator(options::Shutdown::GracefulBlockingConnections( async move {
            shutdown.recv().await.ok();
            info!(l, "Shutting down FTP server");
        }))
        .metrics();

Let me know if you have more input.

@hannesdejager
Copy link
Collaborator

By the way feel free to share your use case for libunftp. It's always interesting for us :-).

@bahlo
Copy link
Author

bahlo commented Nov 12, 2021

That looks great, can't wait!

My use case: I have a printer with a scanner on top and I want to use that to scan documents (paperless and all that), but I 1. don't want to upload them to Dropbox or whatever the printer supports unencrypted and 2. don't want to send them via email.

So I use libunftp to expose an FTP server in my local network that, when a file is uploaded will run OCR, store it locally and send a link via email that only resolves locally. That way I can save the document directly to my encrypted storage.

hannesdejager added a commit that referenced this issue Nov 12, 2021
hannesdejager added a commit that referenced this issue Nov 12, 2021
hannesdejager added a commit that referenced this issue Nov 12, 2021
hannesdejager added a commit that referenced this issue Nov 12, 2021
hannesdejager added a commit that referenced this issue Nov 12, 2021
hannesdejager added a commit that referenced this issue Nov 12, 2021
hannesdejager added a commit that referenced this issue Nov 12, 2021
hannesdejager added a commit that referenced this issue Nov 12, 2021
@hannesdejager
Copy link
Collaborator

Very nice!

hannesdejager added a commit that referenced this issue Nov 12, 2021
hannesdejager added a commit that referenced this issue Nov 12, 2021
hannesdejager added a commit that referenced this issue Nov 12, 2021
hannesdejager added a commit that referenced this issue Nov 13, 2021
hannesdejager added a commit that referenced this issue Nov 13, 2021
@hannesdejager
Copy link
Collaborator

Available in version 0.18.2

@hannesdejager
Copy link
Collaborator

Ready for consumption @bahlo :-)

@bahlo
Copy link
Author

bahlo commented Nov 21, 2021

Thanks, appreciate it! ❤️

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