mirror of
https://github.com/simplex-chat/simplexmq.git
synced 2026-03-30 16:26:02 +00:00
* Add env lookups for smp server paths Allows running smp-server without touching system paths. Can be helpful for running multiple instances. * allow empty env var values * diff * fix --------- Co-authored-by: Evgeny Poberezkin <2769109+epoberezkin@users.noreply.github.com>
28 lines
722 B
Haskell
28 lines
722 B
Haskell
{-# LANGUAGE LambdaCase #-}
|
|
|
|
module Main where
|
|
|
|
import Control.Logger.Simple
|
|
import Data.Maybe
|
|
import Simplex.Messaging.Server.Main
|
|
import System.Environment
|
|
|
|
defaultCfgPath :: FilePath
|
|
defaultCfgPath = "/etc/opt/simplex"
|
|
|
|
defaultLogPath :: FilePath
|
|
defaultLogPath = "/var/opt/simplex"
|
|
|
|
logCfg :: LogConfig
|
|
logCfg = LogConfig {lc_file = Nothing, lc_stderr = True}
|
|
|
|
main :: IO ()
|
|
main = do
|
|
setLogLevel LogDebug
|
|
cfgPath <- getEnvPath "SMP_SERVER_CFG_PATH" defaultCfgPath
|
|
logPath <- getEnvPath "SMP_SERVER_LOG_PATH" defaultLogPath
|
|
withGlobalLogging logCfg $ smpServerCLI cfgPath logPath
|
|
|
|
getEnvPath :: String -> FilePath -> IO FilePath
|
|
getEnvPath name def = maybe def (\case "" -> def; f -> f) <$> lookupEnv name
|