summaryrefslogtreecommitdiffstats
path: root/src/Much/API.hs
diff options
context:
space:
mode:
authortv <tv@krebsco.de>2020-09-29 22:27:04 +0200
committertv <tv@krebsco.de>2020-09-29 22:28:58 +0200
commitbc75dbe4a72210352c2b1c0983b35658d307dca5 (patch)
tree5357f1efcb00e6920cece7b3cd3714d6c487cbbb /src/Much/API.hs
parenteb61952f07e04e60a27a82783569fb65b6281789 (diff)
Much.API: make socket configurable
Diffstat (limited to 'src/Much/API.hs')
-rw-r--r--src/Much/API.hs13
1 files changed, 7 insertions, 6 deletions
diff --git a/src/Much/API.hs b/src/Much/API.hs
index 5810c92..0c1bf8d 100644
--- a/src/Much/API.hs
+++ b/src/Much/API.hs
@@ -1,15 +1,17 @@
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE LambdaCase #-}
+{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE TypeOperators #-}
-module Much.API where
+module Much.API (module Much.API) where
import Control.Concurrent
import Control.Exception (catch, finally, throwIO)
import Control.Monad.IO.Class
import Data.Function ((&))
import Data.Proxy (Proxy)
+import Much.API.Config as Much.API
import Much.Event
import Much.State
import Much.TreeView
@@ -34,12 +36,11 @@ type API =
api :: Proxy API
api = Proxy
-main :: (Event -> IO ()) -> IO ()
-main putEvent = do
+main :: Config -> (Event -> IO ()) -> IO ()
+main Config{socketPath} putEvent = do
sock <- socket AF_UNIX Stream defaultProtocol
- let sockFile = "/home/tv/tmp/much/warp.sock" -- PID?
- removeIfExists sockFile
- bind sock $ SockAddrUnix sockFile
+ removeIfExists socketPath
+ bind sock $ SockAddrUnix socketPath
listen sock maxListenQueue
let settings = defaultSettings
& setPort 0