Skip to content

Commit

Permalink
update hails to new versions
Browse files Browse the repository at this point in the history
  • Loading branch information
Deian Stefan committed Oct 8, 2014
1 parent 07f5037 commit 75e164d
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 16 deletions.
6 changes: 1 addition & 5 deletions Hails/Database/TCB.hs
Original file line number Diff line number Diff line change
Expand Up @@ -276,11 +276,7 @@ execMongoActionTCB act = do
let pipe = dbActionPipe s
mode = dbActionMode s
db = databaseName . dbActionDB $ s
liftLIO $ ioTCB $ do
res <- Mongo.access pipe mode db act
case res of
Left err -> throwIO $ ExecFailure err
Right v -> return v
liftLIO $ ioTCB $ Mongo.access pipe mode db act


--
Expand Down
2 changes: 1 addition & 1 deletion Hails/PolicyModule.hs
Original file line number Diff line number Diff line change
Expand Up @@ -431,7 +431,7 @@ withPolicyModule act = do
List.lookup "HAILS_MONGODB_SERVER" env
mode = maybe master parseMode $
List.lookup "HAILS_MONGODB_MODE" env
pipe <- ioTCB $ Mongo.runIOE $ Mongo.connect (Mongo.host hostName)
pipe <- ioTCB $ Mongo.connect (Mongo.host hostName)
let priv = PrivTCB (toCNF pmOwner)
s0 = makeDBActionStateTCB priv dbName pipe mode
-- Execute policy module entry function with raised clearance:
Expand Down
8 changes: 5 additions & 3 deletions hails.cabal
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Name: hails
Version: 0.11.1.2
Version: 0.11.1.3
build-type: Simple
License: GPL-2
License-File: LICENSE
Expand Down Expand Up @@ -102,12 +102,13 @@ Library
,bson
,mongoDB
,network
,network-uri
,http-conduit >= 2.1.0
,conduit
,conduit-extra
,resourcet
,exceptions
,wai >= 2.1
,wai >= 2.1 && < 3.0
,wai-app-static
,wai-extra
,http-types
Expand Down Expand Up @@ -165,12 +166,13 @@ Executable hails
,bson
,mongoDB
,network
,network-uri
,http-conduit >= 2.1.0
,conduit
,conduit-extra
,resourcet
,exceptions
,wai >= 2.1
,wai >= 2.1 && < 3.0
,wai-extra
,wai-app-static
,warp
Expand Down
18 changes: 11 additions & 7 deletions hails.hs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import Control.Exception
import qualified Data.ByteString.Char8 as S8
import qualified Data.ByteString.Lazy.Char8 as L8

import Prelude
import qualified Data.Text as T
import Data.List (isPrefixOf, isSuffixOf)
import qualified Data.List as List
Expand All @@ -21,7 +22,6 @@ import Hails.Version
import Network.Wai.Handler.Warp
import Network.Wai.Middleware.RequestLogger

import System.Posix.Env (setEnv)
import System.Environment
import System.Console.GetOpt hiding (Option)
import qualified System.Console.GetOpt as GetOpt
Expand Down Expand Up @@ -77,7 +77,7 @@ main = do
cleanOpts opts'
maybe (return ()) (optsToFile opts) $ optOutFile opts
putStrLn $ "Working environment:\n\n" ++ optsToEnvStr opts
forM_ (optsToEnv opts) $ \(k,v) -> setEnv k v True
forM_ (optsToEnv opts) $ \(k,v) -> setEnv k v
let port = fromJust $ optPort opts
hmac_key = L8.pack . fromJust $ optHmacKey opts
persona = personaAuth hmac_key $ T.pack . fromJust . optPersonaAud $ opts
Expand Down Expand Up @@ -107,20 +107,24 @@ loadApp :: Bool -- -XSafe ?
-> IO (DC Application)
loadApp safe mpkgDb appName = do
case mpkgDb of
Just pkgDb -> setEnv "GHC_PACKAGE_PATH" pkgDb True
Just pkgDb -> setEnv "GHC_PACKAGE_PATH" pkgDb
Nothing -> return ()
eapp <- runInterpreter $ do
loadModules [appName]
when safe $
set [languageExtensions := [asExtension "Safe"]]
loadModules [appName]
setImports ["Prelude", "LIO", "LIO.DCLabel", "Hails.HttpServer", appName]
setTopLevelModules [appName]
setImports ["Prelude", "LIO", "LIO.DCLabel", "Hails.HttpServer"]
entryFunType <- typeOf "server"
if entryFunType == "DC Application" then
interpret "server" (undefined :: DC Application)
else
interpret "return server" (undefined :: DC Application)
case eapp of
Left err -> throwIO err
Left err -> case err of
WontCompile es -> do putStrLn (unlines $ map errMsg es)
throwIO (userError "Compilation error")
_ -> throwIO err
Right app -> return app

--
Expand Down Expand Up @@ -397,7 +401,7 @@ envFromFile file = do
let (key',val') = S8.span (/='=') line
val = safeTail val'
in case S8.words key' of
[key] -> setEnv (S8.unpack key) (S8.unpack val) True
[key] -> setEnv (S8.unpack key) (S8.unpack val)
_ -> do hPutStrLn stderr $ "Invalid environment line: " ++
show (S8.unpack line)
exitFailure
Expand Down

0 comments on commit 75e164d

Please sign in to comment.