From 4846547f48b34a31fc89fce82f788294bfeeaceb Mon Sep 17 00:00:00 2001 From: Steffen Jost Date: Fri, 26 Nov 2021 15:55:52 +0100 Subject: [PATCH] chore(status): show build age in days --- src/Handler/Health.hs | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/src/Handler/Health.hs b/src/Handler/Health.hs index 8cc60de6d..ed31be102 100644 --- a/src/Handler/Health.hs +++ b/src/Handler/Health.hs @@ -102,20 +102,27 @@ getInstanceR = do -- Most simple page for simple liveness checks getStatusR :: Handler Html getStatusR = do - currtime <- show <$> liftIO getCurrentTime - withUrlRenderer + currtime <- liftIO getCurrentTime + withUrlRenderer [hamlet| $doctype 5 - Alive + <title>Status <body> <p> - Current Time {#{currtime}} + Current Time #{show currtime} <p> - Compile Time {#{comptime}} + Compile Time #{show comptime} + $maybe ctime <- readMay comptime + <p> + Build is #{show $ ddays ctime currtime} days old |] where - -- vnr_full :: Text = $(embedStringFile "nix/docker/version.json") -- nix/ files not accessible on build server - comptime :: Text = $(stringE =<< runIO (show <$> getCurrentTime)) - \ No newline at end of file + -- vnr_full :: Text = $(embedStringFile "nix/docker/version.json") -- nix/ files not accessible during container construction + + comptime :: Text + comptime = $(stringE =<< runIO (show <$> getCurrentTime)) + + ddays :: UTCTime -> UTCTime -> Double + ddays tstart tstop = (/10) $ fromIntegral $ round $ diffUTCTime tstop tstart / (6 * 60 * 24)