fix: Properly close unix domain socket on exit
This commit is contained in:
committed by
Remo Rechkemmer
parent
387c387073
commit
59f0fe5b32
@@ -21,12 +21,11 @@ import Protolude
|
|||||||
|
|
||||||
-- | Run the PostgREST application with user defined socket.
|
-- | Run the PostgREST application with user defined socket.
|
||||||
runAppInSocket :: Warp.Settings -> Application -> FileMode -> FilePath -> IO ()
|
runAppInSocket :: Warp.Settings -> Application -> FileMode -> FilePath -> IO ()
|
||||||
runAppInSocket settings app socketFileMode socketFilePath = do
|
runAppInSocket settings app socketFileMode socketFilePath =
|
||||||
sock <- createAndBindSocket
|
bracket createAndBindSocket Socket.close $ \socket -> do
|
||||||
putStrLn $ ("Listening on unix socket " :: Text) <> show socketFilePath
|
putStrLn $ ("Listening on unix socket " :: Text) <> show socketFilePath
|
||||||
Socket.listen sock Socket.maxListenQueue
|
Socket.listen socket Socket.maxListenQueue
|
||||||
Warp.runSettingsSocket settings sock app
|
Warp.runSettingsSocket settings socket app
|
||||||
Socket.close sock
|
|
||||||
where
|
where
|
||||||
createAndBindSocket = do
|
createAndBindSocket = do
|
||||||
deleteSocketFileIfExist socketFilePath
|
deleteSocketFileIfExist socketFilePath
|
||||||
|
|||||||
Reference in New Issue
Block a user