mirror of
https://github.com/aelve/guide.git
synced 2024-11-23 12:15:06 +03:00
Use atomic createCheckpointAndClose because atomic = good
This commit is contained in:
parent
4530cc6249
commit
3acd358438
@ -152,10 +152,8 @@ mainWith config = do
|
|||||||
-- 'createCheckpoint', etc
|
-- 'createCheckpoint', etc
|
||||||
let prepare = openLocalStateFrom "state/" emptyState
|
let prepare = openLocalStateFrom "state/" emptyState
|
||||||
finalise db = do
|
finalise db = do
|
||||||
putStrLn "Creating an acid-state checkpoint"
|
putStrLn "Creating an acid-state checkpoint and closing acid-state"
|
||||||
createCheckpoint' db
|
createCheckpointAndClose' db
|
||||||
putStrLn "Closing acid-state"
|
|
||||||
closeAcidState db
|
|
||||||
-- Killing EKG has to be done last, because of
|
-- Killing EKG has to be done last, because of
|
||||||
-- <https://github.com/tibbe/ekg/issues/62>
|
-- <https://github.com/tibbe/ekg/issues/62>
|
||||||
putStrLn "Killing EKG"
|
putStrLn "Killing EKG"
|
||||||
|
@ -33,6 +33,7 @@ module Guide.ServerStuff
|
|||||||
|
|
||||||
-- * Other helpers
|
-- * Other helpers
|
||||||
createCheckpoint',
|
createCheckpoint',
|
||||||
|
createCheckpointAndClose',
|
||||||
)
|
)
|
||||||
where
|
where
|
||||||
|
|
||||||
@ -45,6 +46,7 @@ import qualified Web.Spock as Spock
|
|||||||
import Web.Routing.Combinators (PathState(..))
|
import Web.Routing.Combinators (PathState(..))
|
||||||
-- acid-state
|
-- acid-state
|
||||||
import Data.Acid as Acid
|
import Data.Acid as Acid
|
||||||
|
import Data.Acid.Local as Acid
|
||||||
|
|
||||||
import Guide.Config
|
import Guide.Config
|
||||||
import Guide.State
|
import Guide.State
|
||||||
@ -316,3 +318,14 @@ createCheckpoint' db = liftIO $ do
|
|||||||
when wasDirty $ do
|
when wasDirty $ do
|
||||||
createArchive db
|
createArchive db
|
||||||
createCheckpoint db
|
createCheckpoint db
|
||||||
|
|
||||||
|
-- | Like 'createCheckpointAndClose', but doesn't create a checkpoint if
|
||||||
|
-- there were no changes made.
|
||||||
|
createCheckpointAndClose' :: MonadIO m => DB -> m ()
|
||||||
|
createCheckpointAndClose' db = liftIO $ do
|
||||||
|
wasDirty <- Acid.update db UnsetDirty
|
||||||
|
if wasDirty then do
|
||||||
|
createArchive db
|
||||||
|
createCheckpointAndClose db
|
||||||
|
else do
|
||||||
|
closeAcidState db
|
||||||
|
Loading…
Reference in New Issue
Block a user