Revision c62df702
b/src/Ganeti/Confd/Server.hs | ||
---|---|---|
33 | 33 |
|
34 | 34 |
import Control.Concurrent |
35 | 35 |
import Control.Exception |
36 |
import Control.Monad (forever, liftM, when) |
|
36 |
import Control.Monad (forever, liftM, when, unless)
|
|
37 | 37 |
import Data.IORef |
38 | 38 |
import Data.List |
39 | 39 |
import qualified Data.Map as M |
... | ... | |
112 | 112 |
data ConfigReload = ConfigToDate -- ^ No need to reload |
113 | 113 |
| ConfigReloaded -- ^ Configuration reloaded |
114 | 114 |
| ConfigIOError -- ^ Error during configuration reload |
115 |
deriving (Eq) |
|
115 | 116 |
|
116 | 117 |
-- | Unknown entry standard response. |
117 | 118 |
queryUnknownEntry :: StatusAnswer |
... | ... | |
522 | 523 |
-- | Main function. |
523 | 524 |
main :: MainFn (S.Family, S.SockAddr) PrepResult |
524 | 525 |
main _ _ (s, query_data, cref) = do |
526 |
-- Inotify setup |
|
527 |
inotify <- initINotify |
|
525 | 528 |
-- try to load the configuration, if possible |
526 | 529 |
conf_file <- Path.clusterConfFile |
527 |
(fstat, _) <- safeUpdateConfig conf_file nullFStat cref
|
|
530 |
(fstat, reloaded) <- safeUpdateConfig conf_file nullFStat cref
|
|
528 | 531 |
ctime <- getCurrentTime |
529 |
statemvar <- newMVar $ ServerState initialPoll ctime fstat |
|
530 |
hmac <- getClusterHmac |
|
531 |
-- Inotify setup |
|
532 |
inotify <- initINotify |
|
532 |
statemvar <- newMVar $ ServerState ReloadNotify ctime fstat |
|
533 | 533 |
let inotiaction = addNotifier inotify conf_file cref statemvar |
534 |
has_inotify <- if reloaded == ConfigReloaded |
|
535 |
then inotiaction |
|
536 |
else return False |
|
537 |
if has_inotify |
|
538 |
then logInfo "Starting up in inotify mode" |
|
539 |
else do |
|
540 |
-- inotify was not enabled, we need to update the reload model |
|
541 |
logInfo "Starting up in polling mode" |
|
542 |
modifyMVar_ statemvar |
|
543 |
(\state -> return state { reloadModel = initialPoll }) |
|
544 |
hmac <- getClusterHmac |
|
534 | 545 |
-- fork the timeout timer |
535 | 546 |
_ <- forkIO $ onTimeoutTimer inotiaction conf_file cref statemvar |
536 | 547 |
-- fork the polling timer |
537 |
_ <- forkIO $ onReloadTimer inotiaction conf_file cref statemvar |
|
548 |
unless has_inotify $ do |
|
549 |
_ <- forkIO $ onReloadTimer inotiaction conf_file cref statemvar |
|
550 |
return () |
|
538 | 551 |
-- launch the queryd listener |
539 | 552 |
_ <- forkIO $ runQueryD query_data (configReader cref) |
540 | 553 |
-- and finally enter the responder loop |
Also available in: Unified diff