1
0
mirror of https://github.com/actix/actix-extras.git synced 2025-06-25 18:09:22 +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

@ -11,7 +11,4 @@ path = "src/main.rs"
env_logger = "*"
futures = "0.1"
actix = "^0.3.5"
#actix-web = { git = "https://github.com/actix/actix-web.git" }
actix-web = { path="../../", features=["signal"] }
actix-web = { git = "https://github.com/actix/actix-web.git", features=["signal"] }

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();