diff --git a/htools/Ganeti/Confd/Server.hs b/htools/Ganeti/Confd/Server.hs index 2f7e49ea0911b2adab2bc87d66df56ea919904c6..ee837c1636bd5e23876fd963a63fdac52fcb05d2 100644 --- a/htools/Ganeti/Confd/Server.hs +++ b/htools/Ganeti/Confd/Server.hs @@ -31,7 +31,7 @@ module Ganeti.Confd.Server import Control.Concurrent import Control.Exception -import Control.Monad (forever) +import Control.Monad (forever, liftM) import qualified Data.ByteString as B import Data.IORef import Data.List @@ -54,6 +54,7 @@ import Ganeti.Config import Ganeti.Hash import Ganeti.Logging import qualified Ganeti.Constants as C +import Ganeti.Queryd (runQueryD) -- * Types and constants definitions @@ -515,6 +516,12 @@ listener s hmac resp = do else logDebug "Invalid magic code!" >> return () return () +-- | Extract the configuration from our IORef. +configReader :: CRef -> IO (Result ConfigData) +configReader cref = do + cdata <- readIORef cref + return $ liftM fst cdata + -- | Main function. main :: DaemonOptions -> IO () main opts = do @@ -532,5 +539,7 @@ main opts = do _ <- forkIO $ onTimeoutTimer inotiaction C.clusterConfFile cref statemvar -- fork the polling timer _ <- forkIO $ onReloadTimer inotiaction C.clusterConfFile cref statemvar + -- launch the queryd listener + _ <- forkIO $ runQueryD Nothing (configReader cref) -- and finally enter the responder loop forever $ listener s hmac (responder cref)