Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Log exceptions in Curator to see when the STM exceptions happen #284

Merged
merged 2 commits into from
Jun 19, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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