Missteps of a Narwhal Calf

Previous Entry Share Next Entry
Help! Can you run Happstack as a CGI?
king, avatar, owl, ozten, austin
Does anyone already have code for running a Happstack app as a CGi instead of a HTTP Server?

Searching for a CGI adapter or backend to Happstack, I didn't find anything. The documentation mentions you can do it... but it isn't clear if it works out of the box.

I was able to find the happstack-fastcgi package. For fun, I tried converting my app to fast-cgi, following the blog post announcing the project. No dice.
I changed
main = handleSqlError $ trace "Starting up, try port 8080" (simpleHTTP (Conf 8080 Nothing) $ handleRequest)

main = simpleCGI handleRequest

simpleCGI :: (ToMessage a) => ServerPartT IO a -> IO ()
simpleCGI = runFastCGIConcurrent 10 . serverPartToCGI 

I compiled with
ghc --make -package cgi -package xhtml -o main.fcgi Main.hs

when I run it via apache I get
[Tue Sep 01 23:11:12 2009] [error] [client] FastCGI: incomplete headers (0 bytes) received from server "/home/some/web/main.fcgi"

I'd really like to find out how to run my app under plain old CGI, so that I can host it at NearlyFreeSpeech. They don't support FastCGI, nor long running processes like the Server mode.

  • 1
Don't use the FCGI hooks.

Just compile your application, and throw the binary in your CGI directory. CGI isn't special. It just feeds HTTP requests to an application via some environment variables.

Probably a bad idea though. You will need to make sure that each instance is single threaded and that there can't be race conditions in your state.
(Frozen) (Thread)

  • 1

Log in

No account? Create an account