From ab16187271d2bf51a8af797e091cf81de6f8d2c7 Mon Sep 17 00:00:00 2001 From: Jose Quintana <1700322+joseluisq@users.noreply.github.com> Date: Sun, 5 Nov 2023 07:30:46 +0100 Subject: [PATCH] refactor: improve server maintenance mode logging (#282) --- docs/content/features/maintenance-mode.md | 3 +++ src/maintenance_mode.rs | 7 ++++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/docs/content/features/maintenance-mode.md b/docs/content/features/maintenance-mode.md index 696149a..33a241a 100644 --- a/docs/content/features/maintenance-mode.md +++ b/docs/content/features/maintenance-mode.md @@ -25,6 +25,9 @@ The value should be an existing local HTML file path. When not provided a generi !!! tip "Optional" Remember that either `--maintenance-mode-status` and `--maintenance-mode-file` are optional and can be omitted as needed. +!!! info "Independent path" + The `--maintenance-mode-file` is an independent file path and not relative to the root. + ## Example For instance, the server will respond with a `503 Service Unavailable` status code and a custom message. diff --git a/src/maintenance_mode.rs b/src/maintenance_mode.rs index 06ea099..4a9414a 100644 --- a/src/maintenance_mode.rs +++ b/src/maintenance_mode.rs @@ -22,13 +22,18 @@ pub fn get_response( file_path: &Path, ) -> Result> { tracing::debug!("server has entered into maintenance mode"); + tracing::debug!("maintenance mode file path to use: {}", file_path.display()); let mut body_content = String::new(); - if file_path.exists() { + if file_path.is_file() { body_content = String::from_utf8_lossy(&helpers::read_bytes_default(file_path)) .to_string() .trim() .to_owned(); + } else { + tracing::debug!( + "maintenance mode file path not found or not a regular file, using a default message" + ); } if body_content.is_empty() { -- libgit2 1.7.2