diff options
| author | Joey Hess <joey@kitenet.net> | 2014-05-01 10:49:52 -0300 |
|---|---|---|
| committer | Joey Hess <joey@kitenet.net> | 2014-05-01 10:49:52 -0300 |
| commit | 6088df9105a10ef446cc236982c2e30857182a84 (patch) | |
| tree | a407345854637915fca54e61a68819731b375e05 /Propellor/SimpleSh.hs | |
| parent | f058e47574603fffffc3f60305bc874b78f7770f (diff) | |
| parent | 2bc9a2a7379f80595f5b8f3dc5475f64d5537cfc (diff) | |
Merge branch 'joeyconfig'
Diffstat (limited to 'Propellor/SimpleSh.hs')
| -rw-r--r-- | Propellor/SimpleSh.hs | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/Propellor/SimpleSh.hs b/Propellor/SimpleSh.hs index c088eda7..73ff41ae 100644 --- a/Propellor/SimpleSh.hs +++ b/Propellor/SimpleSh.hs @@ -70,13 +70,17 @@ simpleSh namedpipe = do simpleShClient :: FilePath -> String -> [String] -> ([Resp] -> IO a) -> IO a simpleShClient namedpipe cmd params handler = do + debug ["simplesh connecting"] s <- socket AF_UNIX Stream defaultProtocol connect s (SockAddrUnix namedpipe) h <- socketToHandle s ReadWriteMode hPutStrLn h $ show $ Cmd cmd params hFlush h + debug ["simplesh sent command"] resps <- catMaybes . map readish . lines <$> hGetContents h - hClose h `after` handler resps + v <- hClose h `after` handler resps + debug ["simplesh processed response"] + return v simpleShClientRetry :: Int -> FilePath -> String -> [String] -> ([Resp] -> IO a) -> IO a simpleShClientRetry retries namedpipe cmd params handler = go retries @@ -88,7 +92,8 @@ simpleShClientRetry retries namedpipe cmd params handler = go retries v <- tryIO run case v of Right r -> return r - Left _ -> do + Left e -> do + debug ["simplesh connection retry", show e] threadDelaySeconds (Seconds 1) go (n - 1) |
