Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Print ping timestamps for debugging

Seeing a log of when the service was pinged is helpful during
debugging.
  • Loading branch information...
commit 60e6ad53adac0a875e2770deea816daff03d6511 1 parent 157894d
@mndrix authored
Showing with 7 additions and 0 deletions.
  1. +7 −0 is-online.hs
View
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)
Please sign in to comment.
Something went wrong with that request. Please try again.