From 8743719183abfa10d089c6e7e765e49f6da3c50d Mon Sep 17 00:00:00 2001 From: Steffen Jost Date: Tue, 11 Jan 2022 17:55:20 +0100 Subject: [PATCH] feat(status): show instance running time --- src/Application.hs | 1 + src/Foundation/Type.hs | 1 + src/Handler/Health.hs | 14 +++++++++++--- 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/src/Application.hs b/src/Application.hs index cfa04f60a..5f6ff7bc9 100644 --- a/src/Application.hs +++ b/src/Application.hs @@ -207,6 +207,7 @@ makeFoundation appSettings''@AppSettings{..} = do for_ (guardOnM (isn't _JobsOffload appJobMode) appInjectFiles) $ \_ -> void . Prometheus.register $ injectInhibitMetrics appFileInjectInhibit + appStartTime <- liftIO getCurrentTime -- We need a log function to create a connection pool. We need a connection -- pool to create our foundation. And we need our foundation to get a -- logging function. To get out of this loop, we initially create a diff --git a/src/Foundation/Type.hs b/src/Foundation/Type.hs index 8a4a38c23..0c7468be1 100644 --- a/src/Foundation/Type.hs +++ b/src/Foundation/Type.hs @@ -96,6 +96,7 @@ data UniWorX = UniWorX , appFileInjectInhibit :: TVar (IntervalMap UTCTime (Set FileContentReference)) , appPersonalisedSheetFilesSeedKey :: PersonalisedSheetFilesSeedKey , appVolatileClusterSettingsCache :: TVar VolatileClusterSettingsCache + , appStartTime :: UTCTime -- for Status Page } deriving (Typeable) makeLenses_ ''UniWorX diff --git a/src/Handler/Health.hs b/src/Handler/Health.hs index d4c7194cd..a45efdc35 100644 --- a/src/Handler/Health.hs +++ b/src/Handler/Health.hs @@ -102,6 +102,7 @@ getInstanceR = do -- Most simple page for simple liveness checks getStatusR :: Handler Html getStatusR = do + starttime <- getsYesod appStartTime currtime <- liftIO getCurrentTime withUrlRenderer [hamlet| @@ -111,12 +112,19 @@ getStatusR = do Status <body> <p> - Current Time #{show currtime} + Current Time <br> + #{show currtime} <p> - Compile Time #{comptime} + Instance Start <br> + #{show starttime} + <p> + Compile Time <br> + #{comptime} + <p> + Instance running time is #{show $ ddays starttime currtime} days. $maybe ctime <- readMay comptime <p> - Build is #{show $ ddays ctime currtime} days old + Build is #{show $ ddays ctime currtime} days old. |] where -- vnr_full :: Text = $(embedStringFile "nix/docker/version.json") -- nix/ files not accessible during container construction