summaryrefslogtreecommitdiff
path: root/src/Propellor/Engine.hs
diff options
context:
space:
mode:
authorJoey Hess2015-10-27 17:02:23 -0400
committerJoey Hess2015-10-27 17:02:23 -0400
commit20b04d366b2cff90c39d06fd424ae3e8b67e49f6 (patch)
tree2ebd3fdbacb20ab42bc7ce6b331f99336f551fed /src/Propellor/Engine.hs
parent6e3b0022fa451181fdce8abd145e27a64a777711 (diff)
make Propellor.Message use lock to handle concurrent threads outputting messages
Not yet handled: Output from concurrent programs.
Diffstat (limited to 'src/Propellor/Engine.hs')
-rw-r--r--src/Propellor/Engine.hs33
1 files changed, 1 insertions, 32 deletions
diff --git a/src/Propellor/Engine.hs b/src/Propellor/Engine.hs
index f0bcdac8..36a05b28 100644
--- a/src/Propellor/Engine.hs
+++ b/src/Propellor/Engine.hs
@@ -9,14 +9,12 @@ module Propellor.Engine (
fromHost,
fromHost',
onlyProcess,
- processChainOutput,
) where
import System.Exit
import System.IO
import Data.Monoid
import Control.Applicative
-import System.Console.ANSI
import "mtl" Control.Monad.RWS.Strict
import System.PosixCompat
import System.Posix.IO
@@ -29,8 +27,6 @@ import Propellor.Exception
import Propellor.Info
import Propellor.Property
import Utility.Exception
-import Utility.PartialPrelude
-import Utility.Monad
-- | Gets the Properties of a Host, and ensures them all,
-- with nice display of what's being done.
@@ -38,9 +34,7 @@ mainProperties :: Host -> IO ()
mainProperties host = do
ret <- runPropellor host $
ensureProperties [ignoreInfo $ infoProperty "overall" (ensureProperties ps) mempty mempty]
- whenConsole $
- setTitle "propellor: done"
- hFlush stdout
+ messagesDone
case ret of
FailedChange -> exitWith (ExitFailure 1)
_ -> exitWith ExitSuccess
@@ -98,28 +92,3 @@ onlyProcess lockfile a = bracket lock unlock (const a)
return l
unlock = closeFd
alreadyrunning = error "Propellor is already running on this host!"
-
--- | Reads and displays each line from the Handle, except for the last line
--- which is a Result.
-processChainOutput :: Handle -> IO Result
-processChainOutput h = go Nothing
- where
- go lastline = do
- v <- catchMaybeIO (hGetLine h)
- debug ["read from chained propellor: ", show v]
- case v of
- Nothing -> case lastline of
- Nothing -> do
- debug ["chained propellor output nothing; assuming it failed"]
- return FailedChange
- Just l -> case readish l of
- Just r -> pure r
- Nothing -> do
- debug ["chained propellor output did not end with a Result; assuming it failed"]
- putStrLn l
- hFlush stdout
- return FailedChange
- Just s -> do
- maybe noop (\l -> unless (null l) (putStrLn l)) lastline
- hFlush stdout
- go (Just s)