summaryrefslogtreecommitdiff
path: root/bragi/thermoprint-server/thermoprint-server.hs
blob: 4f909f8040b5fe34640496cd9bd304b1e1a5f10d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
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
      }