diff options
author | Gregor Kleen <gkleen@yggdrasil.li> | 2017-03-06 21:13:03 +0100 |
---|---|---|
committer | Gregor Kleen <gkleen@yggdrasil.li> | 2017-03-06 21:13:03 +0100 |
commit | cf8aef18aad8e92f699165350ec4e18a0f2ee3f5 (patch) | |
tree | a860ca4c37602d646a5b9a90a7fa37e8701e5405 /bragi/thermoprint-server | |
parent | 523df0e6643c63a6927bac7f4de8be42f1484b8d (diff) | |
download | nixos-cf8aef18aad8e92f699165350ec4e18a0f2ee3f5.tar nixos-cf8aef18aad8e92f699165350ec4e18a0f2ee3f5.tar.gz nixos-cf8aef18aad8e92f699165350ec4e18a0f2ee3f5.tar.bz2 nixos-cf8aef18aad8e92f699165350ec4e18a0f2ee3f5.tar.xz nixos-cf8aef18aad8e92f699165350ec4e18a0f2ee3f5.zip |
Migrate thermoprint-server to postgresql
Diffstat (limited to 'bragi/thermoprint-server')
-rw-r--r-- | bragi/thermoprint-server/thermoprint-server.hs | 30 |
1 files changed, 30 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..4f909f80 --- /dev/null +++ b/bragi/thermoprint-server/thermoprint-server.hs | |||
@@ -0,0 +1,30 @@ | |||
1 | {-# LANGUAGE OverloadedStrings #-} | ||
2 | {-# LANGUAGE ImpredicativeTypes #-} | ||
3 | |||
4 | module Main (main) where | ||
5 | |||
6 | import Thermoprint.Server | ||
7 | |||
8 | import Thermoprint.Server.Printer.Generic | ||
9 | |||
10 | import Control.Monad.Trans.Resource | ||
11 | import Control.Monad.Logger | ||
12 | import Control.Monad.Reader | ||
13 | |||
14 | import Database.Persist.Postgresql | ||
15 | |||
16 | main :: IO () | ||
17 | main = thermoprintServer True (Nat runDb) $ (\c -> c { queueManagers = queueManagers }) <$> def `withPrinters` printers | ||
18 | where | ||
19 | runDb :: ReaderT ConnectionPool (LoggingT IO) a -> IO a | ||
20 | runDb = runStderrLoggingT . withPostgresqlPool "" 5 . runReaderT | ||
21 | |||
22 | printers = [ (pure $ genericPrint "/dev/usb/lp0", def) | ||
23 | ] | ||
24 | |||
25 | queueManagers _ = QMConfig | ||
26 | { manager = union [ limitHistorySize 100 | ||
27 | , limitHistoryAge 3600 | ||
28 | ] | ||
29 | , collapse = standardCollapse | ||
30 | } | ||