Skip to content
Browse files

Print ping timestamps for debugging

Seeing a log of when the service was pinged is helpful during
  • Loading branch information...
1 parent 157894d commit 60e6ad53adac0a875e2770deea816daff03d6511 @mndrix committed Feb 8, 2012
Showing with 7 additions and 0 deletions.
  1. +7 −0 is-online.hs
7 is-online.hs
@@ -5,12 +5,16 @@ import Control.Concurrent.MVar
import Control.Monad
import Control.Monad.Trans
import Data.String
+import Data.Time.Clock
+import Data.Time.Format
+import Data.Time.LocalTime
import Network.HTTP.Types
import Network.Wai
import Network.Wai.Handler.Warp
import System.Environment
import System.Exit
import System.IO
+import System.Locale
import System.Process
import Text.Printf
import qualified Data.ByteString as B
@@ -60,6 +64,9 @@ app ekg req = case rawPathInfo req of
pong ekg = do
liftIO $ do
putStrLn "I was pinged."
+ tz <- getCurrentTimeZone
+ now <- utcToLocalTime tz `fmap` getCurrentTime
+ putStrLn $ formatTime defaultTimeLocale "%F %T" now
awaitDeath ekg
e <- readMVar ekg
when (offline e) (incrPings ekg)

0 comments on commit 60e6ad5

Please sign in to comment.
Something went wrong with that request. Please try again.