summaryrefslogtreecommitdiff
path: root/bragi/thermoprint-server/thermoprint-server.hs
diff options
context:
space:
mode:
Diffstat (limited to 'bragi/thermoprint-server/thermoprint-server.hs')
-rw-r--r--bragi/thermoprint-server/thermoprint-server.hs16
1 files changed, 12 insertions, 4 deletions
diff --git a/bragi/thermoprint-server/thermoprint-server.hs b/bragi/thermoprint-server/thermoprint-server.hs
index 6142e7d9..97b37374 100644
--- a/bragi/thermoprint-server/thermoprint-server.hs
+++ b/bragi/thermoprint-server/thermoprint-server.hs
@@ -1,5 +1,6 @@
1{-# LANGUAGE OverloadedStrings #-} 1{-# LANGUAGE OverloadedStrings #-}
2{-# LANGUAGE ImpredicativeTypes #-} 2{-# LANGUAGE ImpredicativeTypes #-}
3{-# LANGUAGE RecordWildCards #-}
3 4
4module Main (main) where 5module Main (main) where
5 6
@@ -11,19 +12,22 @@ import Control.Monad.Trans.Resource
11import Control.Monad.Logger 12import Control.Monad.Logger
12import Control.Monad.Reader 13import Control.Monad.Reader
13 14
15import Data.Function ((&))
16
14import Database.Persist.Postgresql 17import Database.Persist.Postgresql
15 18
19import qualified Network.Wai.Handler.Warp as Warp
20
16type ServerM = ReaderT ConnectionPool (LoggingT IO) 21type ServerM = ReaderT ConnectionPool (LoggingT IO)
17 22
18main :: IO () 23main :: IO ()
19main = thermoprintServer True (Nat runDb) $ (\c -> c { queueManagers = queueManagers }) <$> def `withPrinters` printers 24main = thermoprintServer True (Nat runDb) $ configure (\c -> c{..}) <$> def `withPrinters` printers'
20 where 25 where
21 runDb :: ServerM a -> IO a 26 runDb :: ServerM a -> IO a
22 runDb = runStderrLoggingT . withPostgresqlPool "" 5 . runReaderT 27 runDb = runStderrLoggingT . withPostgresqlPool "" 5 . runReaderT
23 28
24 printers :: [(ResourceT ServerM PrinterMethod, QMConfig (ResourceT ServerM))] 29 printers' = [ (pure $ genericPrint "/dev/usb/lp0", def :: QMConfig (ResourceT ServerM))
25 printers = [ (pure $ genericPrint "/dev/usb/lp0", def) 30 ]
26 ]
27 31
28 queueManagers _ = QMConfig 32 queueManagers _ = QMConfig
29 { manager = union [ limitHistorySize 100 33 { manager = union [ limitHistorySize 100
@@ -31,3 +35,7 @@ main = thermoprintServer True (Nat runDb) $ (\c -> c { queueManagers = queueMana
31 ] 35 ]
32 , collapse = standardCollapse 36 , collapse = standardCollapse
33 } 37 }
38
39 warpSettings = Warp.defaultSettings
40 & Warp.setHost "localhost"
41 & Warp.setPort 8080