Skip to content

Commit

Permalink
Fixes for GHC 7.8.4
Browse files Browse the repository at this point in the history
  • Loading branch information
dterei committed Apr 1, 2015
1 parent fd07f47 commit d4d1678
Show file tree
Hide file tree
Showing 8 changed files with 29 additions and 24 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
dist/
cabal-dev/
log/
resources/
.DS_Store
.cabal-sandbox/
cabal.sandbox.config
2 changes: 1 addition & 1 deletion GHCiOnline.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ Executable GHCiOnline
bytestring >= 0.9,
case-insensitive,
containers >= 0.4,
process >= 1,
process >= 1.2,
random >= 1,
snap-core >= 0.9,
snap-server >= 0.9,
Expand Down
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
install:
cp dist/build/GHCiOnline/GHCiOnline /opt/ghc-online/ghci-online
cp -r static/ /opt/ghc-online/
cp prod.env /etc/conf.d/ghci-online
cp dist/build/GHCiOnline/GHCiOnline /var/ghcio/ghcio
cp -r static/ /var/ghcio/
cp prod.env /etc/conf.d/ghcio
cp systemd/*.service /etc/systemd/system/

6 changes: 2 additions & 4 deletions prod.env
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
CJAIL_PATH=/opt/ghc-online/jail/

CJAIL_PATH=/var/ghcio/jail
GHCI_PATH=/usr/bin/ghci-safe
GHCI_ARGS=-XSafe, -fpackage-trust, -distrust-all-packages, -trust base

HTML_ROOT=/opt/ghc-online/static/
HTML_ROOT=/home/davidt/Projects/GhciOnline/static/
20 changes: 11 additions & 9 deletions src/CJail/System/Process.hs
Original file line number Diff line number Diff line change
Expand Up @@ -228,15 +228,17 @@ mkCreateProcess :: CJailConf -> CreateProcess -> P.CreateProcess
mkCreateProcess conf cp =
let (cjail, cjailArgs) = confToCmdArgs conf
in P.CreateProcess
{ P.cmdspec = RawCommand cjail $
cjailArgs ++ cmdSpecToArgs (cmdspec cp)
, P.cwd = cwd cp
, P.env = Just $ env cp
, P.std_in = P.CreatePipe
, P.std_out = P.CreatePipe
, P.std_err = P.CreatePipe
, P.close_fds = True
, P.create_group = False }
{ P.cmdspec = RawCommand cjail $
cjailArgs ++ cmdSpecToArgs (cmdspec cp)
, P.cwd = cwd cp
, P.env = Just $ env cp
, P.std_in = P.CreatePipe
, P.std_out = P.CreatePipe
, P.std_err = P.CreatePipe
, P.close_fds = True
, P.create_group = False
, P.delegate_ctlc = False
}

-- | Conver 'CmdSpec' to list of arguments to @cjail@
cmdSpecToArgs :: CmdSpec -> [String]
Expand Down
10 changes: 8 additions & 2 deletions src/GHCiManager.hs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import Data.Text (Text)
import qualified Data.Text as T
import qualified Data.Text.IO as T
import System.IO
import System.IO.Error

import GHCiParser
import State
Expand All @@ -22,11 +23,10 @@ stdoutSentinel = "01234568909876543210"
stderrSentinel = "oopsthisisnotavariable"

newGHCi :: GhciState -> IO GHCiHandle
newGHCi gst = do
newGHCi gst = flip catchIOError ioHandle $ do
phandle@(ProcessHandle hin hout herr _) <-
createProcess (gsCJail gst) $
proc (gsGhciPath gst) (gsGhciArgs gst)
-- TODO: check this actually worked...
hSetBuffering hin NoBuffering
hSetBuffering hout NoBuffering
hSetBuffering herr NoBuffering
Expand All @@ -37,6 +37,12 @@ newGHCi gst = do
clearHandle hout
return phandle

where
ioHandle err = do
when (isEOFError err) $ do
putStrLn "Couldn't launch GHCi!"
ioError err

killGHCi :: GHCiHandle -> IO ()
killGHCi = terminateProcess

Expand Down
2 changes: 0 additions & 2 deletions src/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ config = setPort 3222 mempty
-- | Main entry point.
main :: IO ()
main = do
putStrLn "Helo World!"
st <- initState
hFlush stdout
httpServe config $ site st
Expand Down Expand Up @@ -69,7 +68,6 @@ startSession gst uid = liftIO $ modifyMVar_ (gsClients gst) $ \st ->
Nothing -> do
h <- liftIO $ newGHCi gst
t <- T.register (gsTimeout gst) $ endSession gst uid
-- let t = undefined
return $ I.insert uid (ClientState h t) st

-- | End a GHCi session for a user.
Expand Down
4 changes: 2 additions & 2 deletions systemd/ghci-online.service → systemd/ghcio.service
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ After=network.target cjail.service

[Service]
Type=simple
EnvironmentFile=/etc/conf.d/ghci-online
ExecStart=/opt/ghc-online/ghci-online
EnvironmentFile=/etc/conf.d/ghcio
ExecStart=/var/ghcio/ghcio
Restart=on-abort
#User=ghcio

Expand Down

0 comments on commit d4d1678

Please sign in to comment.