mirror of
https://github.com/fafhrd91/actix-web
synced 2025-01-18 05:41:50 +01:00
log acctor init errors
This commit is contained in:
parent
f2d42e5e77
commit
e95babf8d3
@ -60,8 +60,8 @@ flate2-rust = ["flate2/rust_backend"]
|
|||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
actix = "0.7.0"
|
actix = "0.7.0"
|
||||||
#actix-net = { git="https://github.com/actix/actix-net.git" }
|
actix-net = { git="https://github.com/actix/actix-net.git" }
|
||||||
actix-net = { path = "../actix-net" }
|
#actix-net = { path = "../actix-net" }
|
||||||
|
|
||||||
base64 = "0.9"
|
base64 = "0.9"
|
||||||
bitflags = "1.0"
|
bitflags = "1.0"
|
||||||
|
@ -51,7 +51,7 @@ type SslConnector = Arc<ClientConfig>;
|
|||||||
feature = "ssl",
|
feature = "ssl",
|
||||||
feature = "tls",
|
feature = "tls",
|
||||||
feature = "rust-tls",
|
feature = "rust-tls",
|
||||||
)))]
|
),))]
|
||||||
type SslConnector = ();
|
type SslConnector = ();
|
||||||
|
|
||||||
use server::IoStream;
|
use server::IoStream;
|
||||||
@ -290,7 +290,7 @@ impl Default for ClientConnector {
|
|||||||
feature = "ssl",
|
feature = "ssl",
|
||||||
feature = "tls",
|
feature = "tls",
|
||||||
feature = "rust-tls",
|
feature = "rust-tls",
|
||||||
)))]
|
),))]
|
||||||
{
|
{
|
||||||
()
|
()
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
use std::net;
|
|
||||||
use std::time::Duration;
|
use std::time::Duration;
|
||||||
|
use std::{fmt, net};
|
||||||
|
|
||||||
use actix_net::server::ServerMessage;
|
use actix_net::server::ServerMessage;
|
||||||
use actix_net::service::{NewService, Service};
|
use actix_net::service::{NewService, Service};
|
||||||
@ -27,6 +27,7 @@ where
|
|||||||
F: Fn() -> T + Send + Clone + 'static,
|
F: Fn() -> T + Send + Clone + 'static,
|
||||||
T::Response: IoStream + Send,
|
T::Response: IoStream + Send,
|
||||||
T: NewService<Request = TcpStream>,
|
T: NewService<Request = TcpStream>,
|
||||||
|
T::InitError: fmt::Debug,
|
||||||
{
|
{
|
||||||
type Io = T::Response;
|
type Io = T::Response;
|
||||||
type NewService = T;
|
type NewService = T;
|
||||||
@ -84,6 +85,7 @@ pub(crate) struct TcpAcceptor<T> {
|
|||||||
impl<T, E> TcpAcceptor<T>
|
impl<T, E> TcpAcceptor<T>
|
||||||
where
|
where
|
||||||
T: NewService<Request = TcpStream, Error = AcceptorError<E>>,
|
T: NewService<Request = TcpStream, Error = AcceptorError<E>>,
|
||||||
|
T::InitError: fmt::Debug,
|
||||||
{
|
{
|
||||||
pub(crate) fn new(inner: T) -> Self {
|
pub(crate) fn new(inner: T) -> Self {
|
||||||
TcpAcceptor { inner }
|
TcpAcceptor { inner }
|
||||||
@ -93,6 +95,7 @@ where
|
|||||||
impl<T, E> NewService for TcpAcceptor<T>
|
impl<T, E> NewService for TcpAcceptor<T>
|
||||||
where
|
where
|
||||||
T: NewService<Request = TcpStream, Error = AcceptorError<E>>,
|
T: NewService<Request = TcpStream, Error = AcceptorError<E>>,
|
||||||
|
T::InitError: fmt::Debug,
|
||||||
{
|
{
|
||||||
type Request = net::TcpStream;
|
type Request = net::TcpStream;
|
||||||
type Response = T::Response;
|
type Response = T::Response;
|
||||||
@ -111,6 +114,7 @@ where
|
|||||||
pub(crate) struct TcpAcceptorResponse<T>
|
pub(crate) struct TcpAcceptorResponse<T>
|
||||||
where
|
where
|
||||||
T: NewService<Request = TcpStream>,
|
T: NewService<Request = TcpStream>,
|
||||||
|
T::InitError: fmt::Debug,
|
||||||
{
|
{
|
||||||
fut: T::Future,
|
fut: T::Future,
|
||||||
}
|
}
|
||||||
@ -118,16 +122,21 @@ where
|
|||||||
impl<T> Future for TcpAcceptorResponse<T>
|
impl<T> Future for TcpAcceptorResponse<T>
|
||||||
where
|
where
|
||||||
T: NewService<Request = TcpStream>,
|
T: NewService<Request = TcpStream>,
|
||||||
|
T::InitError: fmt::Debug,
|
||||||
{
|
{
|
||||||
type Item = TcpAcceptorService<T::Service>;
|
type Item = TcpAcceptorService<T::Service>;
|
||||||
type Error = T::InitError;
|
type Error = T::InitError;
|
||||||
|
|
||||||
fn poll(&mut self) -> Poll<Self::Item, Self::Error> {
|
fn poll(&mut self) -> Poll<Self::Item, Self::Error> {
|
||||||
match self.fut.poll()? {
|
match self.fut.poll() {
|
||||||
Async::NotReady => Ok(Async::NotReady),
|
Ok(Async::NotReady) => Ok(Async::NotReady),
|
||||||
Async::Ready(service) => {
|
Ok(Async::Ready(service)) => {
|
||||||
Ok(Async::Ready(TcpAcceptorService { inner: service }))
|
Ok(Async::Ready(TcpAcceptorService { inner: service }))
|
||||||
}
|
}
|
||||||
|
Err(e) => {
|
||||||
|
error!("Can not create accetor service: {:?}", e);
|
||||||
|
Err(e)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
use std::marker::PhantomData;
|
use std::marker::PhantomData;
|
||||||
use std::net;
|
use std::{fmt, net};
|
||||||
|
|
||||||
use actix_net::either::Either;
|
use actix_net::either::Either;
|
||||||
use actix_net::server::{Server, ServiceFactory};
|
use actix_net::server::{Server, ServiceFactory};
|
||||||
@ -37,6 +37,7 @@ where
|
|||||||
F: Fn() -> H + Send + Clone + 'static,
|
F: Fn() -> H + Send + Clone + 'static,
|
||||||
H: IntoHttpHandler,
|
H: IntoHttpHandler,
|
||||||
A: AcceptorServiceFactory,
|
A: AcceptorServiceFactory,
|
||||||
|
<A::NewService as NewService>::InitError: fmt::Debug,
|
||||||
P: HttpPipelineFactory<H::Handler, Io = A::Io>,
|
P: HttpPipelineFactory<H::Handler, Io = A::Io>,
|
||||||
{
|
{
|
||||||
/// Create http service builder
|
/// Create http service builder
|
||||||
@ -58,6 +59,7 @@ where
|
|||||||
pub fn acceptor<A1>(self, acceptor: A1) -> HttpServiceBuilder<F, H, A1, P>
|
pub fn acceptor<A1>(self, acceptor: A1) -> HttpServiceBuilder<F, H, A1, P>
|
||||||
where
|
where
|
||||||
A1: AcceptorServiceFactory,
|
A1: AcceptorServiceFactory,
|
||||||
|
<A1::NewService as NewService>::InitError: fmt::Debug,
|
||||||
{
|
{
|
||||||
HttpServiceBuilder {
|
HttpServiceBuilder {
|
||||||
acceptor,
|
acceptor,
|
||||||
@ -153,6 +155,7 @@ impl<F, H, A, P> ServiceProvider for HttpServiceBuilder<F, H, A, P>
|
|||||||
where
|
where
|
||||||
F: Fn() -> H + Send + Clone + 'static,
|
F: Fn() -> H + Send + Clone + 'static,
|
||||||
A: AcceptorServiceFactory,
|
A: AcceptorServiceFactory,
|
||||||
|
<A::NewService as NewService>::InitError: fmt::Debug,
|
||||||
P: HttpPipelineFactory<H::Handler, Io = A::Io>,
|
P: HttpPipelineFactory<H::Handler, Io = A::Io>,
|
||||||
H: IntoHttpHandler,
|
H: IntoHttpHandler,
|
||||||
{
|
{
|
||||||
|
@ -1,7 +1,8 @@
|
|||||||
use std::{io, mem, net};
|
use std::{fmt, io, mem, net};
|
||||||
|
|
||||||
use actix::{Addr, System};
|
use actix::{Addr, System};
|
||||||
use actix_net::server::Server;
|
use actix_net::server::Server;
|
||||||
|
use actix_net::service::NewService;
|
||||||
use actix_net::ssl;
|
use actix_net::ssl;
|
||||||
|
|
||||||
use net2::TcpBuilder;
|
use net2::TcpBuilder;
|
||||||
@ -233,6 +234,7 @@ where
|
|||||||
pub(crate) fn listen_with<A>(mut self, lst: net::TcpListener, acceptor: A) -> Self
|
pub(crate) fn listen_with<A>(mut self, lst: net::TcpListener, acceptor: A) -> Self
|
||||||
where
|
where
|
||||||
A: AcceptorServiceFactory,
|
A: AcceptorServiceFactory,
|
||||||
|
<A::NewService as NewService>::InitError: fmt::Debug,
|
||||||
{
|
{
|
||||||
let addr = lst.local_addr().unwrap();
|
let addr = lst.local_addr().unwrap();
|
||||||
self.sockets.push(Socket {
|
self.sockets.push(Socket {
|
||||||
@ -254,7 +256,7 @@ where
|
|||||||
///
|
///
|
||||||
/// HttpServer does not change any configuration for TcpListener,
|
/// HttpServer does not change any configuration for TcpListener,
|
||||||
/// it needs to be configured before passing it to listen() method.
|
/// it needs to be configured before passing it to listen() method.
|
||||||
pub fn listen_tls(mut self, lst: net::TcpListener, acceptor: TlsAcceptor) -> Self {
|
pub fn listen_tls(self, lst: net::TcpListener, acceptor: TlsAcceptor) -> Self {
|
||||||
use actix_net::service::NewServiceExt;
|
use actix_net::service::NewServiceExt;
|
||||||
|
|
||||||
self.listen_with(lst, move || {
|
self.listen_with(lst, move || {
|
||||||
@ -288,7 +290,7 @@ where
|
|||||||
/// Use listener for accepting incoming tls connection requests
|
/// Use listener for accepting incoming tls connection requests
|
||||||
///
|
///
|
||||||
/// This method sets alpn protocols to "h2" and "http/1.1"
|
/// This method sets alpn protocols to "h2" and "http/1.1"
|
||||||
pub fn listen_rustls(mut self, lst: net::TcpListener, config: ServerConfig) -> Self {
|
pub fn listen_rustls(self, lst: net::TcpListener, config: ServerConfig) -> Self {
|
||||||
use super::{RustlsAcceptor, ServerFlags};
|
use super::{RustlsAcceptor, ServerFlags};
|
||||||
use actix_net::service::NewServiceExt;
|
use actix_net::service::NewServiceExt;
|
||||||
|
|
||||||
@ -324,6 +326,7 @@ where
|
|||||||
where
|
where
|
||||||
S: net::ToSocketAddrs,
|
S: net::ToSocketAddrs,
|
||||||
A: AcceptorServiceFactory,
|
A: AcceptorServiceFactory,
|
||||||
|
<A::NewService as NewService>::InitError: fmt::Debug,
|
||||||
{
|
{
|
||||||
let sockets = self.bind2(addr)?;
|
let sockets = self.bind2(addr)?;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user