From 7ec9b3277dc6858c2acf752540526e1ee5db0ea2 Mon Sep 17 00:00:00 2001 From: Ben Sima Date: Wed, 30 Dec 2020 18:03:29 -0500 Subject: que: use EnvironmentFile instead of keyfile --- Biz/Que/Host.hs | 15 ++++++--------- Biz/Que/Host.nix | 1 + 2 files changed, 7 insertions(+), 9 deletions(-) (limited to 'Biz') diff --git a/Biz/Que/Host.hs b/Biz/Que/Host.hs index 3668a29..f41c683 100644 --- a/Biz/Que/Host.hs +++ b/Biz/Que/Host.hs @@ -36,7 +36,6 @@ import Data.HashMap.Lazy (HashMap) import qualified Data.HashMap.Lazy as HashMap import qualified Data.Text.Encoding as Encoding import qualified Data.Text.Lazy as Text.Lazy -import qualified Data.Text.Lazy.IO as Text.Lazy.IO import qualified Network.HTTP.Types.Status as Http import qualified Network.Wai as Wai import qualified Network.Wai.Handler.Warp as Warp @@ -58,9 +57,9 @@ main = Exception.bracket startup shutdown <| uncurry Warp.run let runActionToIO m = runReaderT (runApp m) sync waiapp <- Scotty.scottyAppT runActionToIO <| routes c putText "*" - putText "Que.Host" + putText "que" putText <| "port: " <> (show <| quePort c) - putText <| "skey: " <> (show <| queSkey c) + putText <| "skey: " <> (Text.Lazy.toStrict <| queSkey c) return (quePort c, waiapp) shutdown :: a -> IO a shutdown = pure <. identity @@ -88,12 +87,12 @@ data Config = Config { -- | QUE_PORT quePort :: Warp.Port, -- | QUE_SKEY - queSkey :: FilePath + queSkey :: Text.Lazy.Text } deriving (Generic, Show) instance Envy.DefConfig Config where - defConfig = Config 3000 "/run/skey/que-admin" + defConfig = Config 3000 "admin-key" instance Envy.FromEnv Config @@ -109,8 +108,7 @@ routes cfg = do -- GET /_/dash Scotty.get (Scotty.literal "/_/dash") <| do authkey <- fromMaybe "" > Scotty.text "not allowed: _ is a reserved namespace" >> Scotty.finish diff --git a/Biz/Que/Host.nix b/Biz/Que/Host.nix index e326483..23dab65 100644 --- a/Biz/Que/Host.nix +++ b/Biz/Que/Host.nix @@ -36,6 +36,7 @@ in ''; serviceConfig = { Environment = ["QUE_PORT=${toString cfg.port}"]; + EnvironmentFile = "/run/que/env"; KillSignal = "INT"; Type = "simple"; Restart = "on-abort"; -- cgit v1.2.3