From 31fef68e9c5a1f9e4a4e7d0f5167c5d8bd4d7b3a Mon Sep 17 00:00:00 2001 From: Gregor Kleen Date: Mon, 29 Feb 2016 23:52:04 +0100 Subject: Initial --- thermoprint-server.hs | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 thermoprint-server.hs diff --git a/thermoprint-server.hs b/thermoprint-server.hs new file mode 100644 index 0000000..40d404f --- /dev/null +++ b/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.Sqlite + +main :: IO () +main = thermoprintServer True (Nat runSqlite) $ (\c -> c { queueManagers = queueManagers }) <$> def `withPrinters` printers + where + runSqlite :: ReaderT ConnectionPool (LoggingT IO) a -> IO a + runSqlite = runStderrLoggingT . withSqlitePool "thermoprint.sqlite" 1 . runReaderT + + printers = [ (pure $ genericPrint "/dev/usb/lp0", def) + ] + + queueManagers _ = QMConfig + { manager = union [ limitHistorySize 100 + , limitHistoryAge 3600 + ] + , collapse = standardCollapse + } -- cgit v1.2.3