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