Michael Snoyman 11 years ago
parent
commit
9e8701c431

+ 2 - 0
frameworks/Haskell/yesod/bash_profile.sh

@@ -0,0 +1,2 @@
+# Where to find the ghc and cabal executables
+export PATH="/opt/ghc/7.8.3/bin:/opt/cabal/1.20/bin:$PATH"

+ 8 - 11
frameworks/Haskell/yesod/bench/bench.cabal

@@ -17,19 +17,16 @@ executable         bench
                 GADTs
                 GADTs
                 EmptyDataDecls
                 EmptyDataDecls
 
 
-    build-depends: base                          >= 4          && < 5
-                 , yesod                         == 1.2.2
-                 , yesod-core                    == 1.2.4
-                 , text                          >= 0.11       && < 0.12
-                 , persistent                    >= 1.2        && < 1.3
-                 , persistent-mysql              >= 1.2        && < 1.3
-                 , persistent-mongoDB            >= 1.2        && < 1.3
-                 , warp                          >= 1.3        && < 1.4
-                 , unix                          >= 2.5
-                 , network-conduit               >= 1.0
+    build-depends: base                          >= 4.7        && < 5
+                 , yesod                         >= 1.2.5.2    && < 1.3
+                 , yesod-core                    == 1.2.14     && < 1.3
+                 , text                          >= 0.11       && < 1.2
+                 , persistent                    >= 1.3        && < 1.4
+                 , persistent-mysql              >= 1.3        && < 1.4
+                 , persistent-mongoDB            >= 1.3        && < 1.4
+                 , warp                          >= 2.1        && < 2.2
                  , primitive                     >= 0.5
                  , primitive                     >= 0.5
                  , mwc-random                    >= 0.12
                  , mwc-random                    >= 0.12
                  , pool-conduit                  >= 0.1.2
                  , pool-conduit                  >= 0.1.2
                  , network
                  , network
                  , mongoDB
                  , mongoDB
-                 , aeson

+ 12 - 15
frameworks/Haskell/yesod/bench/src/yesod.hs

@@ -3,6 +3,8 @@
 {-# LANGUAGE RecordWildCards #-}
 {-# LANGUAGE RecordWildCards #-}
 {-# LANGUAGE EmptyDataDecls #-}
 {-# LANGUAGE EmptyDataDecls #-}
 {-# LANGUAGE RankNTypes #-}
 {-# LANGUAGE RankNTypes #-}
+{-# OPTIONS_GHC -fno-warn-orphans #-}
+module Main (main, resourcesApp, Widget, WorldId) where
 import Yesod hiding (Field)
 import Yesod hiding (Field)
 import System.Environment (getArgs)
 import System.Environment (getArgs)
 import qualified Network.Wai.Handler.Warp as Warp
 import qualified Network.Wai.Handler.Warp as Warp
@@ -15,9 +17,6 @@ import Database.MongoDB ((=:), Field((:=)))
 import qualified System.Random.MWC as R
 import qualified System.Random.MWC as R
 import Control.Monad.Primitive (PrimState)
 import Control.Monad.Primitive (PrimState)
 import Control.Monad (replicateM)
 import Control.Monad (replicateM)
-import Data.Conduit.Network (bindPort)
-import System.Posix.Process (forkProcess)
-import Control.Monad (replicateM_)
 import Network (PortID (PortNumber))
 import Network (PortID (PortNumber))
 import Data.Int (Int64)
 import Data.Int (Int64)
 
 
@@ -27,9 +26,9 @@ World sql=World
 |]
 |]
 
 
 data App = App
 data App = App
-    { appGen :: R.Gen (PrimState IO)
-    , mySqlPool :: Pool My.Connection
-    , mongoDBPool :: Pool Mongo.Connection
+    { appGen :: !(R.Gen (PrimState IO))
+    , mySqlPool :: !(Pool My.Connection)
+    , mongoDBPool :: !(Pool Mongo.Connection)
     }
     }
 
 
 -- | Not actually using the non-raw mongoDB.
 -- | Not actually using the non-raw mongoDB.
@@ -141,8 +140,7 @@ instance ToJSON Mongo.Value where
 
 
 main :: IO ()
 main :: IO ()
 main = R.withSystemRandom $ \gen -> do
 main = R.withSystemRandom $ \gen -> do
-    socket <- bindPort 8000 "*"
-    [cores, host] <- getArgs
+    [_cores, host] <- getArgs
     myPool <- My.createMySQLPool My.defaultConnectInfo
     myPool <- My.createMySQLPool My.defaultConnectInfo
         { My.connectUser = "benchmarkdbuser"
         { My.connectUser = "benchmarkdbuser"
         , My.connectPassword = "benchmarkdbpass"
         , My.connectPassword = "benchmarkdbpass"
@@ -161,10 +159,9 @@ main = R.withSystemRandom $ \gen -> do
         , mySqlPool = myPool
         , mySqlPool = myPool
         , mongoDBPool = mongoPool
         , mongoDBPool = mongoPool
         }
         }
-    let run = Warp.runSettingsSocket Warp.defaultSettings
-                { Warp.settingsPort = 8000
-                , Warp.settingsHost = "*"
-                , Warp.settingsOnException = const $ return ()
-                } socket app
-    replicateM_ (read cores - 1) $ forkProcess run
-    run
+    Warp.runSettings
+        ( Warp.setPort 8000
+        $ Warp.setHost "*"
+        $ Warp.setOnException (\_ _ -> return ())
+          Warp.defaultSettings
+        ) app

+ 1 - 1
frameworks/Haskell/yesod/install.sh

@@ -1,3 +1,3 @@
 #!/bin/bash
 #!/bin/bash
 
 
-fw_depends yesod haskell
+fw_depends haskell78

+ 1 - 5
frameworks/Haskell/yesod/setup.py

@@ -5,16 +5,12 @@ import setup_util
 import os
 import os
 
 
 def start(args, logfile, errfile):
 def start(args, logfile, errfile):
-  #setup_util.replace_text("yesod/bench/config/mysql.yml", "host: .*", "host: " + args.database_host)
-  
   subprocess.check_call("cabal update", shell=True, cwd="yesod/bench", stderr=errfile, stdout=logfile)
   subprocess.check_call("cabal update", shell=True, cwd="yesod/bench", stderr=errfile, stdout=logfile)
   subprocess.check_call("cabal install", shell=True, cwd="yesod/bench", stderr=errfile, stdout=logfile)
   subprocess.check_call("cabal install", shell=True, cwd="yesod/bench", stderr=errfile, stdout=logfile)
-  subprocess.check_call("cabal configure", shell=True, cwd="yesod/bench", stderr=errfile, stdout=logfile)
-  subprocess.check_call("cabal build", shell=True, cwd="yesod/bench", stderr=errfile, stdout=logfile)
 
 
   db_host = args.database_host
   db_host = args.database_host
   threads = str(args.max_threads)
   threads = str(args.max_threads)
-  subprocess.Popen("dist/build/bench/bench " + threads + " " + db_host + " +RTS -A4M -N -qg2 -I0 -G2", shell=True, cwd="yesod/bench", stderr=errfile, stdout=logfile)
+  subprocess.Popen("dist/build/bench/bench " + threads + " " + db_host + " +RTS -A32M -N", shell=True, cwd="yesod/bench", stderr=errfile, stdout=logfile)
   return 0
   return 0
 
 
 def stop(logfile, errfile):
 def stop(logfile, errfile):

+ 0 - 6
toolset/setup/linux/frameworks/yesod.sh

@@ -1,6 +0,0 @@
-#!/bin/bash
-
-fw_depends haskell
-
-cabal update
-cabal install yesod persistent-mysql

+ 10 - 0
toolset/setup/linux/languages/haskell78.sh

@@ -0,0 +1,10 @@
+#!/bin/bash -ex
+
+RETCODE=$(fw_exists /opt/ghc/7.8.3/bin/ghc)
+[ ! "$RETCODE" == 0 ] || { return 0; }
+
+lsb_release -a
+
+sudo add-apt-repository -y ppa:hvr/ghc
+sudo apt-get update
+sudo apt-get install -y ghc-7.8.3 cabal-install-1.20 libpcre3-dev