From 21a74a3ffea3d48195d76486a56031b317fa23fa Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Wed, 28 Oct 2015 11:44:05 -0400 Subject: propellor spin --- src/Propellor/Spin.hs | 5 ++++- src/Utility/ConcurrentOutput.hs | 28 ++++++++++------------------ 2 files changed, 14 insertions(+), 19 deletions(-) (limited to 'src') diff --git a/src/Propellor/Spin.hs b/src/Propellor/Spin.hs index 0c457705..36859fb7 100644 --- a/src/Propellor/Spin.hs +++ b/src/Propellor/Spin.hs @@ -206,7 +206,10 @@ updateServer target relay hst connect haveprecompiled getprivdata = sendRepoUrl toh loop (Just NeedPrivData) -> do - sendPrivData hn toh =<< getprivdata + print "START GET PRIVDATA" + pd <- getprivdata + print "GOT PRIVDATA" + sendPrivData hn toh pd loop (Just NeedGitClone) -> do hClose toh diff --git a/src/Utility/ConcurrentOutput.hs b/src/Utility/ConcurrentOutput.hs index 35904cb7..8a4bdcf2 100644 --- a/src/Utility/ConcurrentOutput.hs +++ b/src/Utility/ConcurrentOutput.hs @@ -130,23 +130,19 @@ updateOutputLocker l = do -- as the output lock becomes free. createProcessConcurrent :: P.CreateProcess -> IO (Maybe Handle, Maybe Handle, Maybe Handle, P.ProcessHandle) createProcessConcurrent p - | hasoutput (P.std_out p) || hasoutput (P.std_err p) = + | willoutput (P.std_out p) || willoutput (P.std_err p) = ifM tryTakeOutputLock - ( do - print ("FIRST", pc) - firstprocess - , do - print ("CONCURRENT", pc) - concurrentprocess + ( firstprocess + , concurrentprocess ) | otherwise = P.createProcess p where - hasoutput P.Inherit = True - hasoutput _ = False + willoutput P.Inherit = True + willoutput _ = False - pc = case P.cmdspec p of - P.ShellCommand s -> s - P.RawCommand c ps -> unwords (c:ps) + rediroutput str h + | willoutput str = P.UseHandle h + | otherwise = str firstprocess = do r@(_, _, _, h) <- P.createProcess p @@ -161,12 +157,8 @@ createProcessConcurrent p (toouth, fromouth) <- pipe (toerrh, fromerrh) <- pipe let p' = p - { P.std_out = if hasoutput (P.std_out p) - then P.UseHandle toouth - else P.std_out p - , P.std_err = if hasoutput (P.std_err p) - then P.UseHandle toerrh - else P.std_err p + { P.std_out = rediroutput (P.std_out p) toouth + , P.std_err = rediroutput (P.std_err p) toerrh } r <- P.createProcess p' hClose toouth -- cgit v1.2.3