Skip to content

Commit

Permalink
refs #18: change - add json/utf8 packages, receive code_id and code, …
Browse files Browse the repository at this point in the history
…fake execute code routine
  • Loading branch information
adrysn committed Nov 1, 2016
1 parent a939e2c commit 25752a4
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 9 deletions.
4 changes: 2 additions & 2 deletions haskell/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ RUN apt-get update && apt-get upgrade -y
#RUN apt-get install -y wget zip
RUN apt-get install -y libzmq3-dev

# Install Haskell Platform and zeromq4-haskell
# Install Haskell Platform and required packages
RUN apt-get install -y haskell-platform pkg-config
RUN cabal update
RUN cabal install zeromq4-haskell
RUN cabal install zeromq4-haskell aeson utf8-string

# Secure installation scripts
USER root
Expand Down
32 changes: 25 additions & 7 deletions haskell/run.hs
Original file line number Diff line number Diff line change
@@ -1,15 +1,33 @@
import qualified Data.ByteString.Char8 as C
import qualified Data.ByteString.UTF8 as U
import qualified Data.Map as Map
import Debug.Trace

import Data.Aeson
import System.ZMQ4.Monadic

main :: IO ()

main = do
let port = "tcp://*:2001"
putStrLn "Started..."
let
putStrLn "serving at port 2001..."
runZMQ $ do
skt <- socket Rep
bind skt port
loop skt
putStrLn "exit."

where
loop skt = do
msg <- receive skt
send skt [] msg
loop skt
port = "tcp://*:2001"
loop skt = do
code_id <- receive skt
code <- receive skt

-- TODO: execute code routine
let (out, err, exceptions) = executeCode (show code_id) (U.toString code)

let result = Map.fromList [("stdout", out), ("stderr", err), ("exceptions", exceptions)]
send skt [] code_id
loop skt

executeCode :: String -> String -> (String, String, String)
executeCode code_id code = ("fake out", "fake err", "fake exceptions")

0 comments on commit 25752a4

Please sign in to comment.