1
1
mirror of https://github.com/aelve/guide.git synced 2024-11-23 21:13:07 +03:00

Close acid-state db upon exit or Ctrl-C

This commit is contained in:
Artyom 2016-03-04 18:22:29 +03:00
parent 597bbe1779
commit 5e1f5bf5e7

View File

@ -767,23 +767,23 @@ otherMethods = do
main :: IO ()
main = do
db <- openLocalStateFrom "state/" sampleState
createCheckpoint db
let config = defaultSpockCfg () PCNoDatabase db
runSpock 8080 $ spock config $ do
middleware (staticPolicy (addBase "static"))
-- Main page
Spock.get root $ do
s <- dbQuery GetGlobalState
lucid $ renderRoot s
-- The add/set methods return rendered parts of the structure (added
-- categories, changed items, etc) so that the Javascript part could take
-- them and inject into the page. We don't want to duplicate rendering on
-- server side and on client side.
renderMethods
setMethods
addMethods
otherMethods
bracket (openLocalStateFrom "state/" sampleState) closeAcidState $ \db -> do
createCheckpoint db
let config = defaultSpockCfg () PCNoDatabase db
runSpock 8080 $ spock config $ do
middleware (staticPolicy (addBase "static"))
-- Main page
Spock.get root $ do
s <- dbQuery GetGlobalState
lucid $ renderRoot s
-- The add/set methods return rendered parts of the structure (added
-- categories, changed items, etc) so that the Javascript part could take
-- them and inject into the page. We don't want to duplicate rendering on
-- server side and on client side.
renderMethods
setMethods
addMethods
otherMethods
renderRoot :: GlobalState -> HtmlT IO ()
renderRoot globalState = do