From 37c9d2599001b5e49635f4eea994524d4e115a61 Mon Sep 17 00:00:00 2001 From: Sibi Prabakaran Date: Wed, 26 Apr 2017 20:56:58 +0530 Subject: [PATCH] Add Debug flag --- yesod-bin/Devel.hs | 20 +++++++++++++++++--- yesod/yesod.cabal | 2 +- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/yesod-bin/Devel.hs b/yesod-bin/Devel.hs index 45cb4239..889f91c8 100644 --- a/yesod-bin/Devel.hs +++ b/yesod-bin/Devel.hs @@ -12,7 +12,6 @@ import Control.Applicative ((<|>)) import Control.Concurrent (threadDelay) import Control.Concurrent.Async (race_) import Control.Concurrent.STM -import Control.Concurrent.MVar import qualified Control.Exception.Safe as Ex import Control.Monad (forever, unless, void, when) @@ -145,6 +144,9 @@ reverseProxy opts appPortVar = do let proxyApp = waiProxyToSettings (const $ do appPort <- atomically $ readTVar appPortVar +#if DEBUG + print $ "revProxy: appPort " ++ (show appPort) +#endif return $ ReverseProxy.WPRProxyDest $ ProxyDest "127.0.0.1" appPort) @@ -244,11 +246,22 @@ updateAppPort bs buildStarted appPortVar = do let buildEnd = isInfixOf stackFailureString bs || isInfixOf stackSuccessString bs case (hasStarted, buildEnd) of (False, False) -> do +#if DEBUG + print "updated appPortVar to -1" +#endif atomically $ do writeTVar appPortVar (-1 :: Int) writeTVar buildStarted True - (True, False) -> return () - (_, True) -> atomically $ writeTVar buildStarted False + (True, False) -> do +#if DEBUG + print "ignored" +#endif + return () + (_, True) -> do +#if DEBUG + print "Reset buildStarted to False" +#endif + atomically $ writeTVar buildStarted False -- | Get the set of all flags available in the given cabal file getAvailableFlags :: D.GenericPackageDescription -> Set.Set String @@ -383,6 +396,7 @@ devel opts passThroughArgs = do inner changedVar -- Each time the library builds successfully, run the application + runApp :: TVar Int -> TVar Bool -> String -> IO b runApp appPortVar changedVar develHsPath = do -- Wait for the first change, indicating that the library -- has been built diff --git a/yesod/yesod.cabal b/yesod/yesod.cabal index fdde1f0e..b804714b 100644 --- a/yesod/yesod.cabal +++ b/yesod/yesod.cabal @@ -1,5 +1,5 @@ name: yesod -version: 1.4.5 +version: 1.4.6 license: MIT license-file: LICENSE author: Michael Snoyman