Skip to content

Commit

Permalink
Log exceptions in Curator to see when the STM exceptions happen (pure…
Browse files Browse the repository at this point in the history
  • Loading branch information
f-f authored Jun 19, 2019
1 parent c52af6b commit 168c49c
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 5 deletions.
20 changes: 15 additions & 5 deletions app/Curator.hs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import qualified Data.Map.Strict as Map
import qualified Data.Set as Set
import qualified Data.Text as Text
import qualified Data.Text.Encoding as Encoding
import qualified Data.Time as Time
import qualified Data.Vector as Vector
import qualified Dhall.Core
import qualified Dhall.Map
Expand Down Expand Up @@ -78,10 +79,10 @@ main = do
chanPackageSetsUpdater <- Queue.newTQueueIO

-- Start threads
Concurrent.forkIO $ fetcher token chanFetcher chanMetadataUpdater chanPackageSetsUpdater
Concurrent.forkIO $ spagoUpdater token chanSpagoUpdater chanFetcher
Concurrent.forkIO $ metadataUpdater chanMetadataUpdater
Concurrent.forkIO $ packageSetsUpdater token chanPackageSetsUpdater
spawnThread "fetcher" $ fetcher token chanFetcher chanMetadataUpdater chanPackageSetsUpdater
spawnThread "spagoUpdater" $ spagoUpdater token chanSpagoUpdater chanFetcher
spawnThread "metaUpdater" $ metadataUpdater chanMetadataUpdater
spawnThread "setsUpdater" $ packageSetsUpdater token chanPackageSetsUpdater

{- |
Expand All @@ -105,6 +106,15 @@ main = do

sleep = Concurrent.threadDelay

spawnThread name thread = Concurrent.forkIO $ catch thread $ \(err :: SomeException) -> do
now <- Time.getCurrentTime
BSL.appendFile "curator-errors.log"
$ "Current time: " <> repr now <> "\n"
<> "Got error from thread '" <> name <> "'\n"
<> "Exception was:\n\n"
<> (BSL.fromStrict . Encoding.encodeUtf8 . tshow) err
<> "\n\n\n"

ensureRepo org repo = do
isThere <- testdir $ Turtle.decodeString $ "data" </> repo
-- clone if needed
Expand Down Expand Up @@ -208,7 +218,7 @@ fetcher token controlChan metadataChan psChan = forever $ do
fetchRepoMetadata :: (PackageName, Package) -> IO ()
fetchRepoMetadata (_, Package{ repo = Local _, ..}) = pure ()
fetchRepoMetadata (packageName, Package{ repo = Remote repoUrl, .. }) =
Retry.recoverAll (Retry.fullJitterBackoff 10000 <> Retry.limitRetries 10) $ \Retry.RetryStatus{..} -> do
Retry.recoverAll (Retry.fullJitterBackoff 50000 <> Retry.limitRetries 25) $ \Retry.RetryStatus{..} -> do
let !(owner:repo:_rest)
= Text.split (=='/')
$ Text.replace "https://github.com/" ""
Expand Down
1 change: 1 addition & 0 deletions package.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ executables:
- vector
- temporary
- retry
- time

tests:
spec:
Expand Down

0 comments on commit 168c49c

Please sign in to comment.