Commit 4c3f55b8 authored by Iustin Pop's avatar Iustin Pop

Split queryd run into prepare and exec

This will help with the general daemon split of prepare/run, and flag
errors earlier in the startup.
Signed-off-by: default avatarIustin Pop <iustin@google.com>
Reviewed-by: default avatarMichael Hanselmann <hansmi@google.com>
parent d8e7c45e
......@@ -58,7 +58,7 @@ import Ganeti.Logging
import Ganeti.Utils
import qualified Ganeti.Constants as C
import qualified Ganeti.Path as Path
import Ganeti.Query.Server (runQueryD)
import Ganeti.Query.Server (prepQueryD, runQueryD)
-- * Types and constants definitions
......@@ -526,7 +526,9 @@ main opts _ _ = do
_ <- forkIO $ onTimeoutTimer inotiaction Path.clusterConfFile cref statemvar
-- fork the polling timer
_ <- forkIO $ onReloadTimer inotiaction Path.clusterConfFile cref statemvar
-- prepare the queryd listener
query_data <- prepQueryD Nothing
-- launch the queryd listener
_ <- forkIO $ runQueryD Nothing (configReader cref)
_ <- forkIO $ runQueryD query_data (configReader cref)
-- and finally enter the responder loop
forever $ listener s hmac (responder cref)
......@@ -27,6 +27,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
module Ganeti.Query.Server
( ConfigReader
, prepQueryD
, runQueryD
) where
......@@ -218,13 +219,17 @@ mainLoop creader socket = do
_ <- forkIO $ clientLoop client creader
mainLoop creader socket
-- | Main function that runs the query endpoint. This should be the
-- only one exposed from this module.
runQueryD :: Maybe FilePath -> ConfigReader -> IO ()
runQueryD fpath creader = do
-- | Function that prepares the server socket.
prepQueryD :: Maybe FilePath -> IO (FilePath, S.Socket)
prepQueryD fpath = do
let socket_path = fromMaybe Path.defaultQuerySocket fpath
cleanupSocket socket_path
bracket
(getServer socket_path)
(closeServer socket_path)
(mainLoop creader)
s <- getServer socket_path
return (socket_path, s)
-- | Main function that runs the query endpoint.
runQueryD :: (FilePath, S.Socket) -> ConfigReader -> IO ()
runQueryD (socket_path, server) creader =
finally
(mainLoop creader server)
(closeServer socket_path server)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment