From 09b9e6111670de149820c998f7648c777b76acad Mon Sep 17 00:00:00 2001 From: Eelco Lempsink Date: Sat, 18 Apr 2009 17:10:50 +0200 Subject: [PATCH 1/6] Documentation --- src/Happstack/Server/FastCGI.hs | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/Happstack/Server/FastCGI.hs b/src/Happstack/Server/FastCGI.hs index ae7c956..675d41d 100644 --- a/src/Happstack/Server/FastCGI.hs +++ b/src/Happstack/Server/FastCGI.hs @@ -1,6 +1,14 @@ --- | Running Happstack applications using FastCGI --- | --- | TODO: explanation of how to use this +{- | +Running Happstack applications using FastCGI + +You need to keep a couple things in mind when configuring a FastCGI Happstack application, especially when using Happstack-state. + +There are several ways to let Apache + FastCGI handle your application. + +[Dynamic] This is the easy way. You don't have to configure your server, but can just execute the scripts. FastCGI will spawn instances of your application if needed and kill them if they're not needed anymore. /This might break working with Happstack-state!/ + +[Static] You explicitly need to configure your script in your host config. By default it will only start one process, on server startup. If you want to work with Happstack-state, this is the preferable way, although we have not exhaustively tested that it won't break. +| -} module Happstack.Server.FastCGI (happstackToCGI) where import Control.Applicative From 92a046706e1bb73e5e7b1a8038c8045ecc2b2cde Mon Sep 17 00:00:00 2001 From: Eelco Lempsink Date: Sat, 18 Apr 2009 17:25:31 +0200 Subject: [PATCH 2/6] Re-export Network.FastcCGI, add a build type --- happstack-fastcgi.cabal | 1 + src/Happstack/Server/FastCGI.hs | 6 +++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/happstack-fastcgi.cabal b/happstack-fastcgi.cabal index 3c644ca..c347620 100644 --- a/happstack-fastcgi.cabal +++ b/happstack-fastcgi.cabal @@ -3,6 +3,7 @@ Version: 0.1 Copyright: Tupil Maintainer: ce@tupil.com License: BSD3 +build-type: simple build-depends: base>=2.0, cgi >= 3000.0.0, fastcgi >= 3001.0.2, mtl, happstack-server, containers >= 0.2.0, utf8-string >= 0.3.4, bytestring Synopsis: Happstack extension for use with FastCGI. Description: diff --git a/src/Happstack/Server/FastCGI.hs b/src/Happstack/Server/FastCGI.hs index 675d41d..90615ea 100644 --- a/src/Happstack/Server/FastCGI.hs +++ b/src/Happstack/Server/FastCGI.hs @@ -9,7 +9,11 @@ There are several ways to let Apache + FastCGI handle your application. [Static] You explicitly need to configure your script in your host config. By default it will only start one process, on server startup. If you want to work with Happstack-state, this is the preferable way, although we have not exhaustively tested that it won't break. | -} -module Happstack.Server.FastCGI (happstackToCGI) where +module Happstack.Server.FastCGI + ( module Network.FastCGI + , happstackToCGI + ) + where import Control.Applicative import Data.Char (toLower) From 8a4c904537954e5066d7e662d83eb8fa0c8f40da Mon Sep 17 00:00:00 2001 From: Eelco Lempsink Date: Sat, 18 Apr 2009 17:51:06 +0200 Subject: [PATCH 3/6] Ingore dist --- .gitignore | 1 + 1 file changed, 1 insertion(+) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..1521c8b --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +dist From 6db933527b8ee4df60bff52de5d064a8aec56557 Mon Sep 17 00:00:00 2001 From: Eelco Lempsink Date: Sat, 18 Apr 2009 18:05:11 +0200 Subject: [PATCH 4/6] Better comment --- src/Happstack/Server/FastCGI.hs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Happstack/Server/FastCGI.hs b/src/Happstack/Server/FastCGI.hs index 90615ea..db4c230 100644 --- a/src/Happstack/Server/FastCGI.hs +++ b/src/Happstack/Server/FastCGI.hs @@ -163,8 +163,10 @@ processRequest hs req = (runWebT $ runServerPartT hs req) >>= (return . (maybe standardNotFound = H.setHeader "Content-Type" "text/html" $ toResponse "Not found" +-------------------------------------------------- +-- Copied straight from Lemmih's old happs-fastcgi +-------------------------------------------------- --- TODO: copied straight from Lemmih's old happs-fastcgi responseMessage :: Int -> [Char] responseMessage 100 = "100 Continue" responseMessage 101 = "101 Switching Protocols" From 6eccec78fac59c6cdfa472e5b09586a77dfc51da Mon Sep 17 00:00:00 2001 From: Eelco Lempsink Date: Sat, 18 Apr 2009 18:08:26 +0200 Subject: [PATCH 5/6] Naming --- src/Happstack/Server/FastCGI.hs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Happstack/Server/FastCGI.hs b/src/Happstack/Server/FastCGI.hs index db4c230..b4af305 100644 --- a/src/Happstack/Server/FastCGI.hs +++ b/src/Happstack/Server/FastCGI.hs @@ -11,7 +11,7 @@ There are several ways to let Apache + FastCGI handle your application. | -} module Happstack.Server.FastCGI ( module Network.FastCGI - , happstackToCGI + , serverPartToCGI ) where @@ -31,8 +31,8 @@ import qualified Network.CGI as CGI -- | Converts a Happstack ServerPartT to a CGI handling function. -happstackToCGI ::(ToMessage b) => ServerPartT IO b -> CGI CGIResult -happstackToCGI = convert . processRequest +serverPartToCGI ::(ToMessage b) => ServerPartT IO b -> CGI CGIResult +serverPartToCGI = convert . processRequest convert :: (Request -> IO Response) -> CGI CGIResult From 60fbfb962e51e06eb19b3a10de51ecf609d8436a Mon Sep 17 00:00:00 2001 From: Eelco Lempsink Date: Sat, 18 Apr 2009 18:08:49 +0200 Subject: [PATCH 6/6] Whitespace --- src/Happstack/Server/FastCGI.hs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Happstack/Server/FastCGI.hs b/src/Happstack/Server/FastCGI.hs index b4af305..9c2928d 100644 --- a/src/Happstack/Server/FastCGI.hs +++ b/src/Happstack/Server/FastCGI.hs @@ -31,7 +31,7 @@ import qualified Network.CGI as CGI -- | Converts a Happstack ServerPartT to a CGI handling function. -serverPartToCGI ::(ToMessage b) => ServerPartT IO b -> CGI CGIResult +serverPartToCGI :: (ToMessage b) => ServerPartT IO b -> CGI CGIResult serverPartToCGI = convert . processRequest