From 4e45ce9ed6841ca069fb5fa351220e3acb14006a Mon Sep 17 00:00:00 2001 From: lovasoa Date: Mon, 3 Jul 2023 00:50:20 +0200 Subject: [PATCH] fix compilation of serverless runtime --- src/app_config.rs | 1 + src/webserver/http.rs | 16 +++++++++++++--- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/src/app_config.rs b/src/app_config.rs index d2111514..4d39f482 100644 --- a/src/app_config.rs +++ b/src/app_config.rs @@ -4,6 +4,7 @@ use serde::de::Error; use serde::{Deserialize, Deserializer}; use std::net::{SocketAddr, ToSocketAddrs}; +#[cfg(not(feature = "lambda-web"))] const DEFAULT_DATABASE_FILE: &str = "sqlpage.db"; #[derive(Debug, Deserialize)] diff --git a/src/webserver/http.rs b/src/webserver/http.rs index b0d5573a..d88c5ea3 100644 --- a/src/webserver/http.rs +++ b/src/webserver/http.rs @@ -11,6 +11,7 @@ use actix_web::{ }; use actix_web::body::MessageBody; +use anyhow::Context; use chrono::{DateTime, Utc}; use futures_util::stream::Stream; use futures_util::StreamExt; @@ -428,7 +429,9 @@ pub fn create_app( impl ServiceFactory< ServiceRequest, Config = (), - Response = ServiceResponse, + Response = ServiceResponse< + impl MessageBody, + >, Error = actix_web::Error, InitError = (), >, @@ -460,9 +463,16 @@ pub async fn run_server(config: Config, state: AppState) -> anyhow::Result<()> { #[cfg(feature = "lambda-web")] if lambda_web::is_running_on_lambda() { - lambda_web::run_actix_on_lambda(factory).await?; + lambda_web::run_actix_on_lambda(factory) + .await + .map_err(|e| anyhow::anyhow!("Unable to start the lambda: {e}"))?; return Ok(()); } - HttpServer::new(factory).bind(listen_on)?.run().await?; + HttpServer::new(factory) + .bind(listen_on) + .with_context(|| "Unable to listen to the specified port")? + .run() + .await + .with_context(|| "Unable to start the application")?; Ok(()) }