diff --git a/Cargo.toml b/Cargo.toml index ba48f1c7c..21775a96b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -99,3 +99,5 @@ version_check = "0.1" lto = true opt-level = 3 # debug = true + +[workspace] diff --git a/examples/basic/Cargo.toml b/examples/basic/Cargo.toml index 6bb442e41..d4fc56662 100644 --- a/examples/basic/Cargo.toml +++ b/examples/basic/Cargo.toml @@ -2,6 +2,7 @@ name = "basic" version = "0.1.0" authors = ["Nikolay Kim "] +workspace = "../.." [dependencies] futures = "*" diff --git a/examples/basic/src/main.rs b/examples/basic/src/main.rs index 9895ac946..f3f519807 100644 --- a/examples/basic/src/main.rs +++ b/examples/basic/src/main.rs @@ -9,9 +9,10 @@ use futures::Stream; use actix::*; use actix_web::*; -#[cfg(target_os = "linux")] use actix::actors::signal::{ProcessSignals, Subscribe}; use actix_web::middleware::RequestSession; use futures::future::{FutureResult, result}; +#[cfg(unix)] +use actix::actors::signal::{ProcessSignals, Subscribe}; /// simple handler fn index(mut req: HttpRequest) -> Result { @@ -96,7 +97,9 @@ fn main() { .bind("0.0.0.0:8080").unwrap() .start(); - if cfg!(target_os = "linux") { // Subscribe to unix signals + // Subscribe to unix signals + #[cfg(unix)] + { let signals = Arbiter::system_registry().get::(); signals.send(Subscribe(addr.subscriber())); } diff --git a/examples/diesel/Cargo.toml b/examples/diesel/Cargo.toml index 40e78e307..6e7a23935 100644 --- a/examples/diesel/Cargo.toml +++ b/examples/diesel/Cargo.toml @@ -2,6 +2,7 @@ name = "diesel-example" version = "0.1.0" authors = ["Nikolay Kim "] +workspace = "../.." [dependencies] env_logger = "0.4" diff --git a/examples/json/Cargo.toml b/examples/json/Cargo.toml index 7eb3155e7..e4d7ed8fc 100644 --- a/examples/json/Cargo.toml +++ b/examples/json/Cargo.toml @@ -2,6 +2,7 @@ name = "json-example" version = "0.1.0" authors = ["Nikolay Kim "] +workspace = "../.." [dependencies] bytes = "0.4" diff --git a/examples/json/src/main.rs b/examples/json/src/main.rs index 907eaf51b..296d4a4bc 100644 --- a/examples/json/src/main.rs +++ b/examples/json/src/main.rs @@ -9,7 +9,8 @@ extern crate serde_json; use actix::*; use actix_web::*; -#[cfg(target_os = "linux")] use actix::actors::signal::{ProcessSignals, Subscribe}; +#[cfg(unix)] +use actix::actors::signal::{ProcessSignals, Subscribe}; use bytes::BytesMut; use futures::{Future, Stream}; @@ -96,7 +97,9 @@ fn main() { .shutdown_timeout(1) .start(); - if cfg!(target_os = "linux") { // Subscribe to unix signals + // Subscribe to unix signals + #[cfg(unix)] + { let signals = Arbiter::system_registry().get::(); signals.send(Subscribe(addr.subscriber())); } diff --git a/examples/multipart/Cargo.toml b/examples/multipart/Cargo.toml index 049ca76c5..7a92f465c 100644 --- a/examples/multipart/Cargo.toml +++ b/examples/multipart/Cargo.toml @@ -2,6 +2,7 @@ name = "multipart-example" version = "0.1.0" authors = ["Nikolay Kim "] +workspace = "../.." [[bin]] name = "multipart" diff --git a/examples/multipart/src/main.rs b/examples/multipart/src/main.rs index 78c613622..407365cd6 100644 --- a/examples/multipart/src/main.rs +++ b/examples/multipart/src/main.rs @@ -6,7 +6,8 @@ extern crate futures; use actix::*; use actix_web::*; -#[cfg(target_os = "linux")] use actix::actors::signal::{ProcessSignals, Subscribe}; +#[cfg(unix)] +use actix::actors::signal::{ProcessSignals, Subscribe}; use futures::{Future, Stream}; use futures::future::{result, Either}; @@ -55,7 +56,9 @@ fn main() { .bind("127.0.0.1:8080").unwrap() .start(); - if cfg!(target_os = "linux") { // Subscribe to unix signals + // Subscribe to unix signals + #[cfg(unix)] + { let signals = Arbiter::system_registry().get::(); signals.send(Subscribe(addr.subscriber())); } diff --git a/examples/signals/Cargo.toml b/examples/signals/Cargo.toml index 869dc66e7..9352ef5e7 100644 --- a/examples/signals/Cargo.toml +++ b/examples/signals/Cargo.toml @@ -2,6 +2,7 @@ name = "signals" version = "0.1.0" authors = ["Nikolay Kim "] +workspace = "../.." [[bin]] name = "server" diff --git a/examples/signals/src/main.rs b/examples/signals/src/main.rs index 2571fdb4f..7f939081a 100644 --- a/examples/signals/src/main.rs +++ b/examples/signals/src/main.rs @@ -5,7 +5,8 @@ extern crate env_logger; use actix::*; use actix_web::*; -#[cfg(target_os = "linux")] use actix::actors::signal::{ProcessSignals, Subscribe}; +#[cfg(unix)] +use actix::actors::signal::{ProcessSignals, Subscribe}; struct MyWebSocket; @@ -34,7 +35,9 @@ fn main() { .bind("127.0.0.1:8080").unwrap() .start(); - if cfg!(target_os = "linux") { // Subscribe to unix signals + // Subscribe to unix signals + #[cfg(unix)] + { let signals = Arbiter::system_registry().get::(); signals.send(Subscribe(addr.subscriber())); } diff --git a/examples/state/Cargo.toml b/examples/state/Cargo.toml index c71fc86f8..7e4c7d3dd 100644 --- a/examples/state/Cargo.toml +++ b/examples/state/Cargo.toml @@ -2,6 +2,7 @@ name = "state" version = "0.1.0" authors = ["Nikolay Kim "] +workspace = "../.." [dependencies] futures = "*" diff --git a/examples/state/src/main.rs b/examples/state/src/main.rs index c713e68ec..68e989bf3 100644 --- a/examples/state/src/main.rs +++ b/examples/state/src/main.rs @@ -7,11 +7,14 @@ extern crate actix; extern crate actix_web; extern crate env_logger; -use actix::*; -use actix_web::*; -#[cfg(target_os = "linux")] use actix::actors::signal::{ProcessSignals, Subscribe}; use std::cell::Cell; +use actix::*; +use actix_web::*; +#[cfg(unix)] +use actix::actors::signal::{ProcessSignals, Subscribe}; + +/// Application state struct AppState { counter: Cell, } @@ -55,7 +58,6 @@ impl Handler for MyWebSocket { } } - fn main() { ::std::env::set_var("RUST_LOG", "actix_web=info"); let _ = env_logger::init(); @@ -74,7 +76,9 @@ fn main() { .bind("127.0.0.1:8080").unwrap() .start(); - if cfg!(target_os = "linux") { // Subscribe to unix signals + // Subscribe to unix signals + #[cfg(unix)] + { let signals = Arbiter::system_registry().get::(); signals.send(Subscribe(addr.subscriber())); } diff --git a/examples/template_tera/Cargo.toml b/examples/template_tera/Cargo.toml index 36e8d8e55..791934d09 100644 --- a/examples/template_tera/Cargo.toml +++ b/examples/template_tera/Cargo.toml @@ -2,6 +2,7 @@ name = "template-tera" version = "0.1.0" authors = ["Nikolay Kim "] +workspace = "../.." [dependencies] env_logger = "0.4" diff --git a/examples/template_tera/src/main.rs b/examples/template_tera/src/main.rs index c4f962e73..1b5552234 100644 --- a/examples/template_tera/src/main.rs +++ b/examples/template_tera/src/main.rs @@ -6,7 +6,9 @@ extern crate tera; use actix::*; use actix_web::*; -#[cfg(target_os = "linux")] use actix::actors::signal::{ProcessSignals, Subscribe}; +#[cfg(unix)] +use actix::actors::signal::{ProcessSignals, Subscribe}; + struct State { template: tera::Tera, // <- store tera template in application state @@ -43,7 +45,8 @@ fn main() { .bind("127.0.0.1:8080").unwrap() .start(); - if cfg!(target_os = "linux") { // Subscribe to unix signals + #[cfg(unix)] + { // Subscribe to unix signals let signals = Arbiter::system_registry().get::(); signals.send(Subscribe(addr.subscriber())); } diff --git a/examples/tls/Cargo.toml b/examples/tls/Cargo.toml index eda5e5fc8..a659bc36b 100644 --- a/examples/tls/Cargo.toml +++ b/examples/tls/Cargo.toml @@ -2,6 +2,7 @@ name = "tls-example" version = "0.1.0" authors = ["Nikolay Kim "] +workspace = "../.." [[bin]] name = "server" diff --git a/examples/tls/src/main.rs b/examples/tls/src/main.rs index 3d969d3a4..a754e0738 100644 --- a/examples/tls/src/main.rs +++ b/examples/tls/src/main.rs @@ -8,7 +8,7 @@ use std::io::Read; use actix::*; use actix_web::*; -#[cfg(target_os = "linux")] +#[cfg(unix)] use actix::actors::signal::{ProcessSignals, Subscribe}; /// somple handle @@ -49,7 +49,7 @@ fn main() { .start_ssl(&pkcs12).unwrap(); // Subscribe to unix signals - #[cfg(target_os = "linux")] + #[cfg(unix)] { let signals = Arbiter::system_registry().get::(); signals.send(Subscribe(addr.subscriber())); diff --git a/examples/websocket-chat/Cargo.toml b/examples/websocket-chat/Cargo.toml index 6ca5f0ad3..517cf8163 100644 --- a/examples/websocket-chat/Cargo.toml +++ b/examples/websocket-chat/Cargo.toml @@ -2,6 +2,7 @@ name = "websocket-example" version = "0.1.0" authors = ["Nikolay Kim "] +workspace = "../.." [[bin]] name = "server" diff --git a/examples/websocket-chat/src/main.rs b/examples/websocket-chat/src/main.rs index a0236cbed..a4d3ce333 100644 --- a/examples/websocket-chat/src/main.rs +++ b/examples/websocket-chat/src/main.rs @@ -17,7 +17,8 @@ use std::time::Instant; use actix::*; use actix_web::*; -#[cfg(target_os = "linux")] use actix::actors::signal::{ProcessSignals, Subscribe}; +#[cfg(unix)] +use actix::actors::signal::{ProcessSignals, Subscribe}; mod codec; mod server; @@ -30,7 +31,7 @@ struct WsChatSessionState { } /// Entry point for our route -fn chat_route(req: HttpRequest) -> Result { +fn chat_route(req: HttpRequest) -> Result { ws::start( req, WsChatSession { @@ -215,7 +216,9 @@ fn main() { .bind("127.0.0.1:8080").unwrap() .start(); - if cfg!(target_os = "linux") { // Subscribe to unix signals + // Subscribe to unix signals + #[cfg(unix)] + { let signals = Arbiter::system_registry().get::(); signals.send(Subscribe(addr.subscriber())); }