1
0
mirror of https://github.com/fafhrd91/actix-web synced 2025-07-01 16:55:08 +02:00

add graceful shutdown system

This commit is contained in:
Nikolay Kim
2017-12-28 16:25:47 -08:00
parent 3f4898a6d1
commit 538fea8027
8 changed files with 208 additions and 33 deletions

View File

@ -3,10 +3,22 @@ extern crate actix_web;
extern crate futures;
extern crate env_logger;
use actix::*;
use actix_web::*;
use actix::Arbiter;
use actix::actors::signal::{ProcessSignals, Subscribe};
struct MyWebSocket;
impl Actor for MyWebSocket {
type Context = HttpContext<Self>;
}
impl StreamHandler<ws::Message> for MyWebSocket {}
impl Handler<ws::Message> for MyWebSocket {
fn handle(&mut self, _: ws::Message, _: &mut Self::Context) -> Response<Self, ws::Message> {
Self::empty()
}
}
fn main() {
::std::env::set_var("RUST_LOG", "actix_web=info");
@ -17,6 +29,7 @@ fn main() {
Application::new()
// enable logger
.middleware(middleware::Logger::default())
.resource("/ws/", |r| r.f(|req| ws::start(req, MyWebSocket)))
.resource("/", |r| r.h(httpcodes::HTTPOk))})
.bind("127.0.0.1:8080").unwrap()
.start();