mirror of
https://github.com/simplex-chat/simplexmq.git
synced 2026-03-29 08:00:09 +00:00
* remove monad typeclasses to reduce overhead * remove unliftIO * StrictData * inline * optional agent port * avoid MonadUnliftIO instance (#1078) * avoid MonadUnliftIO instance * simpler liftError' * rename * narrow down instance * revert --------- Co-authored-by: Evgeny Poberezkin <evgeny@poberezkin.com> * logServer --------- Co-authored-by: Alexander Bondarenko <486682+dpwiz@users.noreply.github.com>
47 lines
1.5 KiB
Haskell
47 lines
1.5 KiB
Haskell
{-# LANGUAGE DuplicateRecordFields #-}
|
|
{-# LANGUAGE NamedFieldPuns #-}
|
|
{-# LANGUAGE OverloadedStrings #-}
|
|
{-# LANGUAGE TypeApplications #-}
|
|
|
|
module Main where
|
|
|
|
import Control.Logger.Simple
|
|
import Data.ByteArray (ScrubbedBytes)
|
|
import qualified Data.List.NonEmpty as L
|
|
import qualified Data.Map.Strict as M
|
|
import Simplex.Messaging.Agent.Env.SQLite
|
|
import Simplex.Messaging.Agent.Server (runSMPAgent)
|
|
import Simplex.Messaging.Agent.Store.SQLite (MigrationConfirmation (..))
|
|
import Simplex.Messaging.Client (defaultNetworkConfig)
|
|
import Simplex.Messaging.Transport (TLS, Transport (..))
|
|
|
|
cfg :: AgentConfig
|
|
cfg = defaultAgentConfig
|
|
|
|
agentDbFile :: String
|
|
agentDbFile = "smp-agent.db"
|
|
|
|
agentDbKey :: ScrubbedBytes
|
|
agentDbKey = ""
|
|
|
|
servers :: InitialAgentServers
|
|
servers =
|
|
InitialAgentServers
|
|
{ smp = M.fromList [(1, L.fromList ["smp://bU0K-bRg24xWW__lS0umO1Zdw_SXqpJNtm1_RrPLViE=@localhost:5223"])],
|
|
ntf = [],
|
|
xftp = M.empty,
|
|
netCfg = defaultNetworkConfig
|
|
}
|
|
|
|
logCfg :: LogConfig
|
|
logCfg = LogConfig {lc_file = Nothing, lc_stderr = True}
|
|
|
|
-- Warning: this SMP agent server is experimental - it does not work correctly with multiple connected TCP clients in some cases.
|
|
main :: IO ()
|
|
main = do
|
|
let AgentConfig {tcpPort} = cfg
|
|
putStrLn $ maybe (error "no agent port") (\port -> "SMP agent listening on port " ++ port) tcpPort
|
|
setLogLevel LogInfo -- LogError
|
|
Right st <- createAgentStore agentDbFile agentDbKey False MCConsole
|
|
withGlobalLogging logCfg $ runSMPAgent (transport @TLS) cfg servers st
|