update dependencies
This commit is contained in:
@@ -23,8 +23,15 @@ pub(crate) fn get_caldav_client(
|
||||
username: &str,
|
||||
password: &str,
|
||||
) -> AuthorizedCaldavClient {
|
||||
let https_connector: HttpsConnector<HttpConnector> = HttpsConnectorBuilder::new()
|
||||
.with_webpki_roots()
|
||||
let https_connector = HttpsConnectorBuilder::new()
|
||||
.with_native_roots()
|
||||
.unwrap_or_else(|_| {
|
||||
event!(
|
||||
Level::WARN,
|
||||
"unable to use native root certificates. Using webpki instead"
|
||||
);
|
||||
HttpsConnectorBuilder::new().with_webpki_roots()
|
||||
})
|
||||
.https_only()
|
||||
.enable_http1()
|
||||
.build();
|
||||
|
||||
@@ -69,7 +69,9 @@ pub enum McpServerError {
|
||||
IoError(#[from] std::io::Error),
|
||||
}
|
||||
|
||||
pub async fn serve_in_background(config: Config) -> Result<(CancellationToken, JoinHandle<std::io::Result<()>>), McpServerError> {
|
||||
pub async fn serve_in_background(
|
||||
config: Config,
|
||||
) -> Result<(CancellationToken, JoinHandle<std::io::Result<()>>), McpServerError> {
|
||||
let routes = Json(
|
||||
config
|
||||
.servers
|
||||
@@ -88,19 +90,21 @@ pub async fn serve_in_background(config: Config) -> Result<(CancellationToken, J
|
||||
.unwrap_or(url::Url::parse("http://localhost:8000").unwrap());
|
||||
event!(Level::INFO, "binding address at {bind_address}");
|
||||
|
||||
let tcp_listener = tokio::net::TcpListener::bind(bind_address_format(bind_address))
|
||||
.await?;
|
||||
let tcp_listener = tokio::net::TcpListener::bind(bind_address_format(bind_address)).await?;
|
||||
|
||||
let cancellation_token = CancellationToken::new();
|
||||
let cloned_cancellation_token = cancellation_token.clone();
|
||||
|
||||
let handle = tokio::task::spawn(axum::serve(tcp_listener, router)
|
||||
.with_graceful_shutdown(async move {
|
||||
select! {
|
||||
_ = cloned_cancellation_token.cancelled() => (),
|
||||
_ = tokio::signal::ctrl_c() => (),
|
||||
}
|
||||
}).into_future());
|
||||
let handle = tokio::task::spawn(
|
||||
axum::serve(tcp_listener, router)
|
||||
.with_graceful_shutdown(async move {
|
||||
select! {
|
||||
_ = cloned_cancellation_token.cancelled() => (),
|
||||
_ = tokio::signal::ctrl_c() => (),
|
||||
}
|
||||
})
|
||||
.into_future(),
|
||||
);
|
||||
|
||||
Ok((cancellation_token, handle))
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
use mcp_server_collection::config::Config;
|
||||
use mcp_server_collection::{serve_in_background, McpServerError};
|
||||
use mcp_server_collection::{McpServerError, serve_in_background};
|
||||
use own_assist_common::{exit_msg, exit_with_error_message, init_tracing_subscriber};
|
||||
use tokio::{main};
|
||||
use tokio::main;
|
||||
|
||||
#[main]
|
||||
async fn main() {
|
||||
@@ -11,10 +11,17 @@ async fn main() {
|
||||
.inspect_err(exit_msg!("Error loading config"))
|
||||
.unwrap();
|
||||
|
||||
let (_, join_handle) = serve_in_background(config).await.inspect_err(|err| match err {
|
||||
McpServerError::McpServerHandlerError(error) => exit_with_error_message(error, "Error handling server"),
|
||||
McpServerError::IoError(error) => exit_with_error_message(error, "Error binding tcp listener")
|
||||
}).unwrap();
|
||||
|
||||
let (_, join_handle) = serve_in_background(config)
|
||||
.await
|
||||
.inspect_err(|err| match err {
|
||||
McpServerError::McpServerHandlerError(error) => {
|
||||
exit_with_error_message(error, "Error handling server")
|
||||
}
|
||||
McpServerError::IoError(error) => {
|
||||
exit_with_error_message(error, "Error binding tcp listener")
|
||||
}
|
||||
})
|
||||
.unwrap();
|
||||
|
||||
join_handle.await.unwrap().unwrap();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user