Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon.

Pages: 1-

Can't get Haskell FastCGI to work.

Name: Anonymous 2009-06-06 20:43

Test.hs

module Main where
import Control.Monad (liftM)
import Data.Maybe (fromMaybe)
import Network.FastCGI
import Text.XHtml.Strict

hello :: Int -> Html
hello 0 = h1 << "Welcome"
          +++ p << "This is the first time I've seen you."
hello c = h1 << "Welcome back!"
          +++ p << ("I have seen you " ++ show c ++ case c of
                                                      1 -> " time before"
                                                      _ -> " times before")

page :: String -> Html -> Html
page t b = header << thetitle << t +++ body << b

cgiMain :: CGI CGIResult
cgiMain = do
  c <- liftM (fromMaybe 0) $ readCookie "mycookie"
  setCookie (newCookie "mycookie" $ show (c + 1))
  output $ showHtml $ page "Cookie example" $ hello c

main :: IO ()
main = runFastCGI $ handleErrors cgiMain



$ ghc --make Test
$ ./Test
Test: user error (FCGX_Accept failed with error code: -88)


Maybe I'll just stick with CGI... how much more resources does plain CGI really take?

Name: Anonymous 2009-06-06 20:47

ARE YOU ME!?

I just started web development today and did a FastCGI BBCode compiler in Haskell.

Test: user error (FCGX_Accept failed with error code: -88)
(I encountered the same error)
You don't run the app yourself. The web server runs it.

Name: Anonymous 2009-06-06 20:48

>>2
And by the same error, I mean exactly the same error with the same error code.

Name: Anonymous 2009-06-06 20:51

I have an Apache server to test it on, and regular CGI works fine, but FastCGI doesn't. I'm sure that the mod_fastcgi is loaded, because Apache says it is.

Are you using Arch Linux, too?

Name: Anonymous 2009-06-06 21:04

>>4
No, I used Debian & lighttpd. I looked at the default mod_fastcgi config file (with PHP preconfigured), and I just copied some entries and changed them so that every time I accessed a file with the .bbcode extension my app was executed.

I'm sure that the mod_fastcgi is loaded, because Apache says it is.
But you need to configure it somehow to execute your program.
Or find out how to do it manually, I'm sure it's also possible since you can have FastCGI processes running on remote hosts somehow.

Name: Anonymous 2013-01-19 23:36

/prog/ will be spammed continuously until further notice. we apologize for any inconvenience this may cause.

Don't change these.
Name: Email:
Entire Thread Thread List