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

Handle SIGTERM properly #183

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

denverdino
Copy link

Signed-off-by: Li Yi [email protected]

Fix #182

Tested in Mac/Linux

$ cargo run -- -c examples/modules.toml
    Finished dev [unoptimized + debuginfo] target(s) in 1.03s
     Running `target/debug/wagi -c examples/modules.toml`
No log_dir specified, using temporary directory /var/folders/jh/x0hxxwzn7j7fhmlh3q3k17x40000gp/T/.tmp9evE6D for logs
Ready: serving on http://127.0.0.1:3000

In the separated terminal

$ kill -15 PROCESS_ID

@ghost
Copy link

ghost commented Jun 2, 2022

CLA assistant check
All CLA requirements met.

@itowlson
Copy link
Contributor

itowlson commented Jun 7, 2022

Sorry for the lack of reply - I've been away. Thanks for this - I'll take a look!

Copy link
Contributor

@itowlson itowlson left a comment

Choose a reason for hiding this comment

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

Couple of things, hopefully minor. Thanks!

@@ -11,13 +11,19 @@ use hyper::{
use hyper::{Body, Response, Server};
use tokio::net::TcpStream;
use tokio_rustls::server::TlsStream;
use tokio::signal::unix::SignalKind;
Copy link
Contributor

Choose a reason for hiding this comment

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

Will this work on Windows? Might need to be conditionally compiled...

.await?;
let server = Server::builder(tls::TlsHyperAcceptor::new(&self.address, &tls.cert_path, &tls.key_path).await?)
.serve(mk_svc);
let graceful = server.with_graceful_shutdown(shutdown_signal());
Copy link
Contributor

Choose a reason for hiding this comment

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

We had problems with with_graceful_shutdown in Spin because it kept the process alive until all connections had closed, which could be a couple of minutes due to keep-alives. See fermyon/spin#73 for the problem and links to relevant Hyper issues, and fermyon/spin#232 for how we solved it there.

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.

Support SIGTERM for graceful shutdown in containers
2 participants