packages feed

tmp-postgres 1.16.0.0 → 1.16.1.0

raw patch · 6 files changed

+25/−13 lines, 6 files

Files

CHANGELOG.md view
@@ -1,5 +1,8 @@ Changelog for tmp-postgres +1.16.1.0+  #152 Add stopPostgresGracefully function.+ 1.16.0.0   #149 CopyDirectoryCommand partial and rename the old CopyDirectoryCommand to   CompleteCopyDirectoryCommand.
src/Database/Postgres/Temp.hs view
@@ -60,6 +60,7 @@   , stop   , restart   , stopPostgres+  , stopPostgresGracefully   , startNewDb   , startNewDbConfig   , stopNewDb
src/Database/Postgres/Temp/Internal.hs view
@@ -320,7 +320,7 @@   dbResources@Resources {..} <-     ContT $ bracketOnError (setupConfig extra) cleanupConfig   dbPostgresProcess <--    ContT $ bracketOnError (startPlan resourcesPlan) stopPostgresProcess+    ContT $ bracketOnError (startPlan resourcesPlan) stopPlan   pure DB {..}  -- | Default start behavior. Equivalent to calling 'startConfig' with the@@ -336,7 +336,7 @@ --   @since 1.12.0.0 stop :: DB -> IO () stop DB {..} = do-  void $ stopPostgresProcess dbPostgresProcess+  void $ stopPlan dbPostgresProcess   cleanupConfig dbResources  -- | Only stop the @postgres@ process but leave any temporary resources.@@ -345,8 +345,16 @@ -- --   @since 1.12.0.0 stopPostgres :: DB -> IO ExitCode-stopPostgres = stopPostgresProcess . dbPostgresProcess+stopPostgres = stopPlan . dbPostgresProcess +-- | Only stop the @postgres@ process but leave any temporary resources.+--   In contrast to 'stopPostgres' this function makes sure @postgres@+--   has time to properly write files to the data directory.+--+--   @since 1.16.1.0+stopPostgresGracefully :: DB -> IO ExitCode+stopPostgresGracefully = stopPostgresProcess True . dbPostgresProcess+ -- | Restart the @postgres@ from 'DB' using the prior 'Plan'. -- --   @since 1.12.0.0@@ -356,7 +364,7 @@   let CompletePlan{..} = resourcesPlan dbResources       startAction = startPostgresProcess completePlanConnectionTimeout completePlanLogger         completePlanPostgres-  bracketOnError startAction stopPostgresProcess $ \result ->+  bracketOnError startAction stopPlan $ \result ->     pure $ db { dbPostgresProcess = result }  -- | Reload the configuration file without shutting down. Calls
src/Database/Postgres/Temp/Internal/Core.hs view
@@ -21,7 +21,7 @@ import           System.Directory import           System.Exit (ExitCode(..)) import           System.IO-import           System.Posix.Signals (sigQUIT, signalProcess)+import           System.Posix.Signals (sigINT, sigQUIT, signalProcess) import           System.Process import           System.Process.Internals import           System.Timeout@@ -251,12 +251,12 @@  -- | Stop the @postgres@ process after attempting to terminate all the --   connections.-stopPostgresProcess :: PostgresProcess -> IO ExitCode-stopPostgresProcess PostgresProcess{..} = do+stopPostgresProcess :: Bool -> PostgresProcess -> IO ExitCode+stopPostgresProcess graceful PostgresProcess{..} = do   withProcessHandle postgresProcessHandle $ \case     OpenHandle p   ->       -- Call for "Immediate shutdown"-      signalProcess sigQUIT p+      signalProcess (if graceful then sigINT else sigQUIT) p     OpenExtHandle {} -> pure () -- TODO log windows is not supported     ClosedHandle _ -> return () @@ -273,7 +273,7 @@         <$> startProcess "postgres" completePostgresPlanProcessConfig    -- Start postgres and stop if an exception occurs-  bracketOnError startAction stopPostgresProcess $+  bracketOnError startAction (stopPostgresProcess False) $     \result@PostgresProcess {..} -> do       logger WaitForDB       -- We assume that 'template1' exist and make connection@@ -412,11 +412,11 @@   let startAction = startPostgresProcess         completePlanConnectionTimeout completePlanLogger completePlanPostgres -  bracketOnError startAction stopPostgresProcess $ \result -> do+  bracketOnError startAction (stopPostgresProcess False) $ \result -> do     for_ completePlanCreateDb executeCreateDb      pure result  -- | Stop the @postgres@ process. See 'stopPostgresProcess' for more details. stopPlan :: PostgresProcess -> IO ExitCode-stopPlan = stopPostgresProcess+stopPlan = stopPostgresProcess False
test/Main.hs view
@@ -717,7 +717,7 @@         PG.query_ conn "SELECT id FROM foo ORDER BY id ASC"           `shouldReturn` [PG.Only (1 :: Int), PG.Only 2] -      stopPostgres db `shouldReturn` ExitSuccess+      stopPostgresGracefully db `shouldReturn` ExitSuccess        removeDirectoryRecursive dataDir       createDirectory dataDir
tmp-postgres.cabal view
@@ -1,5 +1,5 @@ name:                tmp-postgres-version:             1.16.0.0+version:             1.16.1.0 synopsis: Start and stop a temporary postgres description: Start and stop a temporary postgres. See README.md homepage:            https://github.com/jfischoff/tmp-postgres#readme