From cf8aef18aad8e92f699165350ec4e18a0f2ee3f5 Mon Sep 17 00:00:00 2001 From: Gregor Kleen Date: Mon, 6 Mar 2017 21:13:03 +0100 Subject: Migrate thermoprint-server to postgresql --- bragi/thermoprint-server/thermoprint-server.hs | 30 ++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 bragi/thermoprint-server/thermoprint-server.hs (limited to 'bragi/thermoprint-server') diff --git a/bragi/thermoprint-server/thermoprint-server.hs b/bragi/thermoprint-server/thermoprint-server.hs new file mode 100644 index 00000000..4f909f80 --- /dev/null +++ b/bragi/thermoprint-server/thermoprint-server.hs @@ -0,0 +1,30 @@ +{-# LANGUAGE OverloadedStrings #-} +{-# LANGUAGE ImpredicativeTypes #-} + +module Main (main) where + +import Thermoprint.Server + +import Thermoprint.Server.Printer.Generic + +import Control.Monad.Trans.Resource +import Control.Monad.Logger +import Control.Monad.Reader + +import Database.Persist.Postgresql + +main :: IO () +main = thermoprintServer True (Nat runDb) $ (\c -> c { queueManagers = queueManagers }) <$> def `withPrinters` printers + where + runDb :: ReaderT ConnectionPool (LoggingT IO) a -> IO a + runDb = runStderrLoggingT . withPostgresqlPool "" 5 . runReaderT + + printers = [ (pure $ genericPrint "/dev/usb/lp0", def) + ] + + queueManagers _ = QMConfig + { manager = union [ limitHistorySize 100 + , limitHistoryAge 3600 + ] + , collapse = standardCollapse + } -- cgit v1.2.3