mirror of
https://github.com/GrammaticalFramework/gf-core.git
synced 2026-04-23 03:32:51 -06:00
pgf-server: write stderr to pgf-error.log, since lighttpd closes stderr for fastcgi processes.
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
{-# LANGUAGE DeriveDataTypeable #-}
|
{-# LANGUAGE DeriveDataTypeable #-}
|
||||||
module FastCGIUtils (initFastCGI, loopFastCGI,
|
module FastCGIUtils (initFastCGI, loopFastCGI,
|
||||||
throwCGIError, handleCGIErrors,
|
throwCGIError, handleCGIErrors,
|
||||||
|
stderrToFile,
|
||||||
outputJSONP,
|
outputJSONP,
|
||||||
splitBy) where
|
splitBy) where
|
||||||
|
|
||||||
@@ -110,6 +111,13 @@ restartIfModified =
|
|||||||
logError :: String -> IO ()
|
logError :: String -> IO ()
|
||||||
logError s = hPutStrLn stderr s
|
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
|
-- * General CGI Error exception mechanism
|
||||||
|
|
||||||
data CGIError = CGIError { cgiErrorCode :: Int, cgiErrorMessage :: String, cgiErrorText :: [String] }
|
data CGIError = CGIError { cgiErrorCode :: Int, cgiErrorMessage :: String, cgiErrorText :: [String] }
|
||||||
|
|||||||
@@ -20,9 +20,12 @@ import Data.Maybe
|
|||||||
import System.Directory
|
import System.Directory
|
||||||
import System.FilePath
|
import System.FilePath
|
||||||
|
|
||||||
|
logFile :: FilePath
|
||||||
|
logFile = "pgf-error.log"
|
||||||
|
|
||||||
main :: IO ()
|
main :: IO ()
|
||||||
main = do initFastCGI
|
main = do stderrToFile logFile
|
||||||
|
initFastCGI
|
||||||
cache <- newCache PGF.readPGF
|
cache <- newCache PGF.readPGF
|
||||||
runFastCGIConcurrent' forkIO 100 (handleErrors (handleCGIErrors (cgiMain cache)))
|
runFastCGIConcurrent' forkIO 100 (handleErrors (handleCGIErrors (cgiMain cache)))
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user