From a16f53288067d7004fafa8c17f60c11e91d1c859 Mon Sep 17 00:00:00 2001 From: Michael Snoyman Date: Fri, 12 Oct 2012 12:17:00 +0200 Subject: [PATCH] extra-hosts --- Keter/App.hs | 7 +++++++ incoming/foo/config/keter.yaml | 2 ++ 2 files changed, 9 insertions(+) diff --git a/Keter/App.hs b/Keter/App.hs index 23c8f15..ad4b201 100644 --- a/Keter/App.hs +++ b/Keter/App.hs @@ -31,6 +31,8 @@ import System.IO (hClose) import qualified Data.ByteString.Lazy as L import Data.Conduit (($$), yield, runResourceT) import Data.Conduit.Binary (sinkFile) +import Data.Set (Set) +import qualified Data.Set as Set data Config = Config { configExec :: F.FilePath @@ -38,6 +40,7 @@ data Config = Config , configHost :: String , configPostgres :: Bool , configSsl :: Bool + , configExtraHosts :: Set String } instance FromJSON Config where @@ -47,6 +50,7 @@ instance FromJSON Config where <*> o .: "host" <*> o .:? "postgres" .!= False <*> o .:? "ssl" .!= False + <*> o .:? "extra-hosts" .!= Set.empty parseJSON _ = fail "Wanted an object" data Command = Reload | Terminate @@ -151,6 +155,7 @@ start tf portman postgres logger appname bundle removeFromList = do if b then do addEntry portman (configHost config) port + mapM_ (flip (addEntry portman) port) $ Set.toList $ configExtraHosts config loop chan dir process port config else do removeFromList @@ -163,6 +168,7 @@ start tf portman postgres logger appname bundle removeFromList = do Terminate -> do removeFromList removeEntry portman $ configHost configOld + mapM_ (removeEntry portman) $ Set.toList $ configExtraHosts configOld log $ TerminatingApp appname terminateOld detach logger @@ -182,6 +188,7 @@ start tf portman postgres logger appname bundle removeFromList = do if b then do addEntry portman (configHost config) port + mapM_ (flip (addEntry portman) port) $ Set.toList $ configExtraHosts config when (configHost config /= configHost configOld) $ removeEntry portman $ configHost configOld log $ FinishedReloading appname diff --git a/incoming/foo/config/keter.yaml b/incoming/foo/config/keter.yaml index b3015cb..98cd770 100644 --- a/incoming/foo/config/keter.yaml +++ b/incoming/foo/config/keter.yaml @@ -2,3 +2,5 @@ exec: ../hello args: - Hello World 1 host: tealc-mint +extra-hosts: + - pong