summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorbjorn <bjorn@bringert.net>2008-11-04 09:28:21 +0000
committerbjorn <bjorn@bringert.net>2008-11-04 09:28:21 +0000
commitf1fcee964fb33ab1a165544f728dcbb1d511657d (patch)
tree84ea4e60a79d1a63bd24372fae77e9228021bdce /src
parenta6905d654df0fd0c90dbae039da9b50288a52026 (diff)
pgf-server: write stderr to pgf-error.log, since lighttpd closes stderr for fastcgi processes.
Diffstat (limited to 'src')
-rw-r--r--src/server/FastCGIUtils.hs8
-rw-r--r--src/server/PGFService.hs5
2 files changed, 12 insertions, 1 deletions
diff --git a/src/server/FastCGIUtils.hs b/src/server/FastCGIUtils.hs
index 615915787..6fef5112d 100644
--- a/src/server/FastCGIUtils.hs
+++ b/src/server/FastCGIUtils.hs
@@ -1,6 +1,7 @@
{-# LANGUAGE DeriveDataTypeable #-}
module FastCGIUtils (initFastCGI, loopFastCGI,
throwCGIError, handleCGIErrors,
+ stderrToFile,
outputJSONP,
splitBy) where
@@ -110,6 +111,13 @@ restartIfModified =
logError :: String -> IO ()
logError s = hPutStrLn stderr s
+stderrToFile :: FilePath -> IO ()
+stderrToFile file =
+ do let mode = ownerModes `unionFileModes` groupReadMode `unionFileModes` otherReadMode
+ fileFd <- openFd file WriteOnly (Just mode) (defaultFileFlags { append = True })
+ dupTo fileFd stdError
+ return ()
+
-- * General CGI Error exception mechanism
data CGIError = CGIError { cgiErrorCode :: Int, cgiErrorMessage :: String, cgiErrorText :: [String] }
diff --git a/src/server/PGFService.hs b/src/server/PGFService.hs
index 3caf36c91..b6a5b8eb6 100644
--- a/src/server/PGFService.hs
+++ b/src/server/PGFService.hs
@@ -20,9 +20,12 @@ import Data.Maybe
import System.Directory
import System.FilePath
+logFile :: FilePath
+logFile = "pgf-error.log"
main :: IO ()
-main = do initFastCGI
+main = do stderrToFile logFile
+ initFastCGI
cache <- newCache PGF.readPGF
runFastCGIConcurrent' forkIO 100 (handleErrors (handleCGIErrors (cgiMain cache)))