Conditional compilation for signal handling
Will not compile on windows
This commit is contained in:
+2
-1
@@ -61,7 +61,8 @@ executable postgrest
|
|||||||
, HTTP, http-types
|
, HTTP, http-types
|
||||||
, MissingH
|
, MissingH
|
||||||
, Ranged-sets
|
, Ranged-sets
|
||||||
, unix >= 2.7 && < 3
|
if !os(windows)
|
||||||
|
build-depends: unix >= 2.7 && < 3
|
||||||
|
|
||||||
hs-source-dirs: src
|
hs-source-dirs: src
|
||||||
other-modules: Paths_postgrest
|
other-modules: Paths_postgrest
|
||||||
|
|||||||
+10
-3
@@ -1,3 +1,5 @@
|
|||||||
|
{-# LANGUAGE CPP #-}
|
||||||
|
|
||||||
module Main where
|
module Main where
|
||||||
|
|
||||||
|
|
||||||
@@ -10,8 +12,6 @@ import PostgREST.DbStructure
|
|||||||
import PostgREST.Error (PgError, pgErrResponse)
|
import PostgREST.Error (PgError, pgErrResponse)
|
||||||
import PostgREST.Middleware
|
import PostgREST.Middleware
|
||||||
|
|
||||||
import Control.Concurrent (myThreadId)
|
|
||||||
import Control.Exception.Base (throwTo, AsyncException(..))
|
|
||||||
import Control.Monad (unless, void)
|
import Control.Monad (unless, void)
|
||||||
import Control.Monad.IO.Class (liftIO)
|
import Control.Monad.IO.Class (liftIO)
|
||||||
import Data.Aeson (encode)
|
import Data.Aeson (encode)
|
||||||
@@ -28,9 +28,14 @@ import Network.Wai.Middleware.RequestLogger (logStdout)
|
|||||||
import System.IO (BufferMode (..),
|
import System.IO (BufferMode (..),
|
||||||
hSetBuffering, stderr,
|
hSetBuffering, stderr,
|
||||||
stdin, stdout)
|
stdin, stdout)
|
||||||
import System.Posix.Signals
|
|
||||||
import Web.JWT (secret)
|
import Web.JWT (secret)
|
||||||
|
|
||||||
|
#ifndef mingw32_HOST_OS
|
||||||
|
import System.Posix.Signals
|
||||||
|
import Control.Concurrent (myThreadId)
|
||||||
|
import Control.Exception.Base (throwTo, AsyncException(..))
|
||||||
|
#endif
|
||||||
|
|
||||||
isServerVersionSupported :: H.Session P.Postgres IO Bool
|
isServerVersionSupported :: H.Session P.Postgres IO Bool
|
||||||
isServerVersionSupported = do
|
isServerVersionSupported = do
|
||||||
Identity (row :: Text) <- H.tx Nothing $ H.singleEx [H.stmt|SHOW server_version_num|]
|
Identity (row :: Text) <- H.tx Nothing $ H.singleEx [H.stmt|SHOW server_version_num|]
|
||||||
@@ -72,11 +77,13 @@ main = do
|
|||||||
<> show minimumPgVersion)
|
<> show minimumPgVersion)
|
||||||
) supportedOrError
|
) supportedOrError
|
||||||
|
|
||||||
|
#ifndef mingw32_HOST_OS
|
||||||
tid <- myThreadId
|
tid <- myThreadId
|
||||||
void $ installHandler keyboardSignal (Catch $ do
|
void $ installHandler keyboardSignal (Catch $ do
|
||||||
H.releasePool pool
|
H.releasePool pool
|
||||||
throwTo tid UserInterrupt
|
throwTo tid UserInterrupt
|
||||||
) Nothing
|
) Nothing
|
||||||
|
#endif
|
||||||
|
|
||||||
let txSettings = Just (H.ReadCommitted, Just True)
|
let txSettings = Just (H.ReadCommitted, Just True)
|
||||||
dbOrError <- H.session pool $ H.tx txSettings $ getDbStructure (cs $ configSchema conf)
|
dbOrError <- H.session pool $ H.tx txSettings $ getDbStructure (cs $ configSchema conf)
|
||||||
|
|||||||
Reference in New Issue
Block a user