@@ -63,8 +63,7 @@ import PostgREST.Version (docsVersion, prettyVersion)
6363
6464import qualified Data.ByteString.Char8 as BS
6565import qualified Data.List as L
66- import Data.Streaming.Network (bindPortTCP ,
67- bindRandomPortTCP )
66+ import Data.Streaming.Network (bindPortTCP )
6867import qualified Data.Text as T
6968import qualified Network.HTTP.Types as HTTP
7069import qualified Network.HTTP.Types.Header as HTTP (hVary )
@@ -262,33 +261,15 @@ type AppSockets = (NS.Socket, Maybe NS.Socket)
262261
263262initSockets :: AppConfig -> IO AppSockets
264263initSockets AppConfig {.. } = do
265- let
266- cfg'usp = configServerUnixSocket
267- cfg'uspm = configServerUnixSocketMode
268- cfg'host = configServerHost
269- cfg'port = configServerPort
270- cfg'adminHost = configAdminServerHost
271- cfg'adminPort = configAdminServerPort
272-
273- sock <- case cfg'usp of
264+ sock <- case configServerUnixSocket of
274265 -- I'm not using `streaming-commons`' bindPath function here because it's not defined for Windows,
275266 -- but we need to have runtime error if we try to use it in Windows, not compile time error
276- Just path -> createAndBindDomainSocket path cfg'uspm
277- Nothing -> do
278- (_, sock) <-
279- if cfg'port /= 0
280- then do
281- sock <- bindPortTCP cfg'port (fromString $ T. unpack cfg'host)
282- pure (cfg'port, sock)
283- else do
284- -- explicitly bind to a random port, returning bound port number
285- (num, sock) <- bindRandomPortTCP (fromString $ T. unpack cfg'host)
286- pure (num, sock)
287- pure sock
288-
289- adminSock <- case cfg'adminPort of
267+ Just path -> createAndBindDomainSocket path configServerUnixSocketMode
268+ Nothing -> bindPortTCP configServerPort (fromString $ T. unpack configServerHost)
269+
270+ adminSock <- case configAdminServerPort of
290271 Just adminPort -> do
291- adminSock <- bindPortTCP adminPort (fromString $ T. unpack cfg'adminHost )
272+ adminSock <- bindPortTCP adminPort (fromString $ T. unpack configAdminServerHost )
292273 pure $ Just adminSock
293274 Nothing -> pure Nothing
294275
0 commit comments