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