mirror of
https://github.com/commercialhaskell/stackage-server.git
synced 2026-01-18 23:21:55 +01:00
Try an explicit database close to flush resources
This commit is contained in:
parent
cc1dc6ffe5
commit
5a6137f7c6
@ -4,6 +4,7 @@ module Stackage.Database
|
|||||||
, SnapName (..)
|
, SnapName (..)
|
||||||
, SnapshotId ()
|
, SnapshotId ()
|
||||||
, Snapshot (..)
|
, Snapshot (..)
|
||||||
|
, closeStackageDatabase
|
||||||
, newestSnapshot
|
, newestSnapshot
|
||||||
, newestLTS
|
, newestLTS
|
||||||
, newestLTSMajor
|
, newestLTSMajor
|
||||||
@ -73,6 +74,7 @@ import qualified Database.Esqueleto as E
|
|||||||
import Data.Yaml (decode)
|
import Data.Yaml (decode)
|
||||||
import qualified Data.Aeson as A
|
import qualified Data.Aeson as A
|
||||||
import Types (SnapshotBranch(..))
|
import Types (SnapshotBranch(..))
|
||||||
|
import Data.Pool (destroyAllResources)
|
||||||
|
|
||||||
currentSchema :: Int
|
currentSchema :: Int
|
||||||
currentSchema = 1
|
currentSchema = 1
|
||||||
@ -153,6 +155,9 @@ _hideUnusedWarnings _ = ()
|
|||||||
|
|
||||||
newtype StackageDatabase = StackageDatabase ConnectionPool
|
newtype StackageDatabase = StackageDatabase ConnectionPool
|
||||||
|
|
||||||
|
closeStackageDatabase :: StackageDatabase -> IO ()
|
||||||
|
closeStackageDatabase (StackageDatabase pool) = destroyAllResources pool
|
||||||
|
|
||||||
class MonadIO m => GetStackageDatabase m where
|
class MonadIO m => GetStackageDatabase m where
|
||||||
getStackageDatabase :: m StackageDatabase
|
getStackageDatabase :: m StackageDatabase
|
||||||
instance MonadIO m => GetStackageDatabase (ReaderT StackageDatabase m) where
|
instance MonadIO m => GetStackageDatabase (ReaderT StackageDatabase m) where
|
||||||
|
|||||||
@ -106,6 +106,7 @@ loadFromS3 develMode man = do
|
|||||||
-- give existing users a chance to clean up
|
-- give existing users a chance to clean up
|
||||||
threadDelay $ 1000000 * 30
|
threadDelay $ 1000000 * 30
|
||||||
void $ tryIO $ removeFile (fromString fp)
|
void $ tryIO $ removeFile (fromString fp)
|
||||||
|
closeStackageDatabase db
|
||||||
return oldKill
|
return oldKill
|
||||||
|
|
||||||
update
|
update
|
||||||
|
|||||||
@ -184,6 +184,7 @@ library
|
|||||||
, amazonka-s3 >= 1.3 && < 1.5
|
, amazonka-s3 >= 1.3 && < 1.5
|
||||||
, lens >= 4.13 && < 4.14
|
, lens >= 4.13 && < 4.14
|
||||||
, file-embed
|
, file-embed
|
||||||
|
, resource-pool
|
||||||
|
|
||||||
executable stackage-server
|
executable stackage-server
|
||||||
if flag(library-only)
|
if flag(library-only)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user