To launch my Yesod application I need to provide an application environment argument for example:
./myYesodApp Production
Is there any way using Yesod to start the application and have the environment set as an environment variable or a configuration setting? So I can simply call:
./myYesodApp
I need to be able to do this so I can run my Yesod app using mod_fastcgi.
Alternatively is there any way to provide this argument to FastCgiWrapper?
My main.hs looks like this:
import Prelude (IO, (>>=))
import Yesod.Default.Config (fromArgs)
import Yesod.Default.Main (defaultMain)
import Settings (parseExtra)
import Application (makeApplication)
import Network.Wai.Handler.FastCGI (run)
main :: IO ()
main = fromArgs parseExtra >>= makeApplication >>= run
I think using withArgs :: [String] -> IO a -> IO a
from System.Environment
will be the easiest way to do this.
main = do
env <- getEnv "YESOD_ENVIRONMENT"
withArgs [env] (fromArgs parseExtra >>= makeApplication >>= run)