propellor-2.16.0: property-based host configuration management in haskell

Safe HaskellNone



This module handles all display of output to the console when propellor is ensuring Properties.

When two threads both try to display a message concurrently, the messages will be displayed sequentially.



getMessageHandle :: IO MessageHandle Source

Gets the global MessageHandle.

isConsole :: MessageHandle -> Bool Source

forceConsole :: IO () Source

Force console output. This can be used when stdout is not directly connected to a console, but is eventually going to be displayed at a console.

actionMessage :: (MonadIO m, MonadMask m, ActionResult r) => Desc -> m r -> m r Source

Shows a message while performing an action, with a colored status display.

actionMessageOn :: (MonadIO m, MonadMask m, ActionResult r) => HostName -> Desc -> m r -> m r Source

Shows a message while performing an action on a specified host, with a colored status display.

infoMessage :: MonadIO m => [String] -> m () Source

processChainOutput :: Handle -> IO Result Source

Reads and displays each line from the Handle, except for the last line which is a Result.

messagesDone :: IO () Source

Called when all messages about properties have been printed.

createProcessConcurrent :: CreateProcess -> IO (Maybe Handle, Maybe Handle, Maybe Handle, ConcurrentProcessHandle) Source

Wrapper around createProcess that prevents multiple processes that are running concurrently from writing to stdout/stderr at the same time.

If the process does not output to stdout or stderr, it's run by createProcess entirely as usual. Only processes that can generate output are handled specially:

A process is allowed to write to stdout and stderr in the usual way, assuming it can successfully take the output lock.

When the output lock is held (ie, by another concurrent process, or because outputConcurrent is being called at the same time), the process is instead run with its stdout and stderr redirected to a buffer. The buffered output will be displayed as soon as the output lock becomes free.

Currently only available on Unix systems, not Windows.

withConcurrentOutput :: (MonadIO m, MonadMask m) => m a -> m a Source

Use this around any actions that use outputConcurrent or createProcessConcurrent

This is necessary to ensure that buffered concurrent output actually gets displayed before the program exits.