Permalink
Browse files

Create directory if missing; some debug stuff and error handling.

  • Loading branch information...
1 parent dc0193c commit 04e3a728882087bb50b08094e5add85400b33b4d @nominolo committed May 3, 2011
Showing with 9 additions and 6 deletions.
  1. +6 −5 src/Scion/Session.hs
  2. +2 −1 src/Scion/Types/Session.hs
  3. +1 −0 src/Scion/Worker/Main.hs
View
@@ -217,11 +217,12 @@ startWorker start_worker homedir conf = do
close_all (inp, out, err, _) =
hClose inp >> hClose out >> hClose err
wait_for_READY h = do
- l <- S.hGetLine h
- if l == str_READY then return () else do
- -- ignore other lines
- putStrLn $ "Worker: " ++ show l
- wait_for_READY h
+ handle (\(_e :: IOError) -> putStrLn "Could not start worker.") $ do
+ l <- S.hGetLine h
+ if l == str_READY then return () else do
+ -- ignore other lines
+ putStrLn $ "Worker: " ++ show l
+ wait_for_READY h
str_READY = S.pack (map (fromIntegral . ord) "READY")
printFromHandle hdl =
@@ -154,7 +154,7 @@ type WorkerStarter =
defaultWorkerStarter :: String -> WorkerStarter
defaultWorkerStarter workername homedir args = do
worker <- do
- bindir <- Info.getBinDir
+ bindir <- Info.getBinDir
has_inplace <- doesFileExist (bindir </> workername)
if has_inplace then return (bindir </> workername)
else do
@@ -164,6 +164,7 @@ defaultWorkerStarter workername homedir args = do
throwIO $ CannotStartWorker $
"Executable \"" ++ workername ++ "\" does not exist"
Just w -> return w
+ --putStrLn $ "Starting worker process: " ++ worker
runInteractiveProcess worker (homedir:args) Nothing Nothing
data CannotStartWorker = CannotStartWorker String
View
@@ -78,6 +78,7 @@ import System.PosixCompat.Files ( getFileStatus, modificationTime )
logfile :: Handle
logfile = unsafePerformIO $ do
path <- getAppUserDataDirectory "scion"
+ createDirectoryIfMissing True path
openFile (path </> "worker-log") AppendMode
debugMsg :: MonadIO m => String -> m ()

0 comments on commit 04e3a72

Please sign in to comment.