Try an explicit database close to flush resources

This commit is contained in:
Michael Snoyman 2017-02-13 20:40:44 +02:00
parent cc1dc6ffe5
commit 5a6137f7c6
3 changed files with 7 additions and 0 deletions

View File

@ -4,6 +4,7 @@ module Stackage.Database
, SnapName (..)
, SnapshotId ()
, Snapshot (..)
, closeStackageDatabase
, newestSnapshot
, newestLTS
, newestLTSMajor
@ -73,6 +74,7 @@ import qualified Database.Esqueleto as E
import Data.Yaml (decode)
import qualified Data.Aeson as A
import Types (SnapshotBranch(..))
import Data.Pool (destroyAllResources)
currentSchema :: Int
currentSchema = 1
@ -153,6 +155,9 @@ _hideUnusedWarnings _ = ()
newtype StackageDatabase = StackageDatabase ConnectionPool
closeStackageDatabase :: StackageDatabase -> IO ()
closeStackageDatabase (StackageDatabase pool) = destroyAllResources pool
class MonadIO m => GetStackageDatabase m where
getStackageDatabase :: m StackageDatabase
instance MonadIO m => GetStackageDatabase (ReaderT StackageDatabase m) where

View File

@ -106,6 +106,7 @@ loadFromS3 develMode man = do
-- give existing users a chance to clean up
threadDelay $ 1000000 * 30
void $ tryIO $ removeFile (fromString fp)
closeStackageDatabase db
return oldKill
update

View File

@ -184,6 +184,7 @@ library
, amazonka-s3 >= 1.3 && < 1.5
, lens >= 4.13 && < 4.14
, file-embed
, resource-pool
executable stackage-server
if flag(library-only)