Skip to content
This repository has been archived by the owner on Mar 4, 2023. It is now read-only.

Commit

Permalink
Create directory if missing; some debug stuff and error handling.
Browse files Browse the repository at this point in the history
  • Loading branch information
nominolo committed May 3, 2011
1 parent dc0193c commit 04e3a72
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
11 changes: 6 additions & 5 deletions src/Scion/Session.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
Expand Down
3 changes: 2 additions & 1 deletion src/Scion/Types/Session.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
1 change: 1 addition & 0 deletions src/Scion/Worker/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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 ()
Expand Down

0 comments on commit 04e3a72

Please sign in to comment.