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:
@ -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"] }
|
||||
|
@ -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();
|
||||
|
Reference in New Issue
Block a user