-
Notifications
You must be signed in to change notification settings - Fork 321
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove unused oneshot channel from USR2 sdf work
This commit removes an unused oneshot channel from the recent USR2 signal handling work in sdf (#4368). Additional changes: - Move the maintenance mode message into a constant in order to make the code more readable - Rename "Result" to "ServerResult" for clarity in "server/server.rs" - Re-order imports to match style Signed-off-by: Nick Gerace <[email protected]>
- Loading branch information
1 parent
d5c7376
commit f4b7278
Showing
2 changed files
with
58 additions
and
66 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,3 @@ | ||
use super::{ | ||
server::ServerError, | ||
state::{AppState, ApplicationRuntimeMode}, | ||
}; | ||
use axum::{ | ||
extract::State, | ||
http::{HeaderValue, Request, StatusCode}, | ||
|
@@ -20,6 +16,13 @@ use thiserror::Error; | |
use tower_http::cors::CorsLayer; | ||
use tower_http::{compression::CompressionLayer, cors::AllowOrigin}; | ||
|
||
use super::{ | ||
server::ServerError, | ||
state::{AppState, ApplicationRuntimeMode}, | ||
}; | ||
|
||
const MAINTENANCE_MODE_MESSAGE: &str = " SI is currently in maintenance mode. Please try again later. Reach out to [email protected] or in the SI Discord for more information if this problem persists"; | ||
|
||
async fn app_state_middeware<B>( | ||
State(state): State<AppState>, | ||
request: Request<B>, | ||
|
@@ -28,7 +31,7 @@ async fn app_state_middeware<B>( | |
match *state.application_runtime_mode.read().await { | ||
ApplicationRuntimeMode::Maintenance => { | ||
// Return a 503 when the server is in maintenance/offline | ||
(StatusCode::SERVICE_UNAVAILABLE, " SI is currently in maintenance mode. Please try again later. Reach out to [email protected] or in the SI Discord for more information if this problem persists").into_response() | ||
(StatusCode::SERVICE_UNAVAILABLE, MAINTENANCE_MODE_MESSAGE).into_response() | ||
} | ||
ApplicationRuntimeMode::Running => next.run(request).await, | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters