From 31168e1cd034aec3c790b10e04ff14e528235781 Mon Sep 17 00:00:00 2001 From: Mariusz Klochowicz Date: Mon, 15 Nov 2021 16:04:57 +1030 Subject: [PATCH 1/2] Reduce log spam by logging heartbeats at trace level This is a periodic message, no need to spam the logs. --- daemon/src/connection.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/daemon/src/connection.rs b/daemon/src/connection.rs index f41c462..2fb0676 100644 --- a/daemon/src/connection.rs +++ b/daemon/src/connection.rs @@ -138,7 +138,7 @@ impl Actor { match msg { wire::MakerToTaker::Heartbeat => { - tracing::info!("got the heartbeat"); + tracing::trace!("received a heartbeat message from maker"); self.connected_state .as_mut() .expect("wire messages only to arrive in connected state") From ef27eff99910e9438d787cf44207160456272fda Mon Sep 17 00:00:00 2001 From: Mariusz Klochowicz Date: Mon, 15 Nov 2021 16:12:19 +1030 Subject: [PATCH 2/2] Improve user-facing string if taker daemon shuts down Make the error toast suggest the next reasonable action in case of such event. --- daemon/src/taker.rs | 2 +- taker-frontend/src/App.tsx | 2 +- taker-frontend/src/components/BackendMonitor.tsx | 5 +++-- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/daemon/src/taker.rs b/daemon/src/taker.rs index 7be0a97..5357472 100644 --- a/daemon/src/taker.rs +++ b/daemon/src/taker.rs @@ -304,7 +304,7 @@ async fn main() -> Result<()> { loop { maker_online_status_feed_receiver.changed().await.unwrap(); if maker_online_status_feed_receiver.borrow().clone() == ConnectionStatus::Offline { - tracing::info!("Maker is offline. Shutting down the taker"); + tracing::info!("Lost connection to maker, shutting down. Please restart the daemon to reconnect"); rocket::Shutdown::notify(shutdown_handle); return; } diff --git a/taker-frontend/src/App.tsx b/taker-frontend/src/App.tsx index 237bf2e..56a1b5f 100644 --- a/taker-frontend/src/App.tsx +++ b/taker-frontend/src/App.tsx @@ -45,7 +45,7 @@ async function postCfdOrderRequest(payload: CfdOrderRequestPayload) { export const App = () => { const toast = useToast(); - useBackendMonitor(toast, 5000); // 5s timeout + useBackendMonitor(toast, 5000, "Please start the taker again to reconnect..."); // 5s timeout const { lastMessage, diff --git a/taker-frontend/src/components/BackendMonitor.tsx b/taker-frontend/src/components/BackendMonitor.tsx index f899a1d..bed7309 100644 --- a/taker-frontend/src/components/BackendMonitor.tsx +++ b/taker-frontend/src/components/BackendMonitor.tsx @@ -13,7 +13,8 @@ async function fetchWithTimeout(resource: any, timeout: number) { // Check for backend's presence by sending a request to '/alive' endpoint. // When the backend's not there, the request is likely to timeout, triggering a // persistent toast notification that goes away when the daemon is back online. -export function useBackendMonitor(toast: any, timeout_ms: number): void { +// `description` is a user-facing string describing problem/possible action. +export function useBackendMonitor(toast: any, timeout_ms: number, description: string): void { const toastIdRef = useRef(); const checkForBackend: () => void = async () => { @@ -31,7 +32,7 @@ export function useBackendMonitor(toast: any, timeout_ms: number): void { if (!toastIdRef.current) { toastIdRef.current = toast({ title: "Connection Error", - description: "Daemon process is not running", + description, status: "error", position: "top", duration: timeout_ms * 100000, // we don't want this to be closed