update heroku instructions

This commit is contained in:
Greg Weber 2012-01-01 22:01:49 -03:00
parent 89e6941dd8
commit 16da67f87f

View File

@ -15,30 +15,62 @@
# #
# Postgresql Yesod setup: # Postgresql Yesod setup:
# #
# * add code to read DATABASE_URL environment variable. # * add code to read the DATABASE_URL environment variable.
# #
# import System.Environment # import System.Environment
# main = do # main = do
# durl <- getEnv "DATABASE_URL"
# # parse env variable # # parse env variable
# durl <- getEnv "DATABASE_URL"
# # pass settings to withConnectionPool instead of directly using loadConnStr # # pass settings to withConnectionPool instead of directly using loadConnStr
# defaultMain (fromArgsExtra loadExtra) withYesodHeroku
# #
# * add a dependency on the "heroku" package in your cabal file # * add a dependency on the "heroku" package in your cabal file
# #
# * add code in Settings.hs to turn that url into connection parameters. The below works for Postgresql. # * add code in Application.hs to turn the url into connection parameters. The below works for Postgresql.
# #
# #ifdef !DEVELOPMENT # #ifdef !DEVELOPMENT
# import qualified Web.Heroku # import qualified Web.Heroku
# #endif # #endif
# #
# dbConnParams :: AppEnvironment -> IO [(Text, Text)] #
# #ifdef !DEVELOPMENT # canonicalizeKey :: (Text, val) -> (Text, val)
# dbConnParams _ = Web.Heroku.dbConnParams # canonicalizeKey ("dbname", val) = ("database", val)
# canonicalizeKey pair = pair
#
# toMapping :: [(key, val)] -> DO.Object key val
# toMapping = DO.Mapping . map (\(key, val) -> (key, DO.Scalar val))
#
# combineMappings :: DO.Object key val -> DO.Object key val -> DO.Object key val
# combineMappings (DO.Mapping m1) (DO.Mapping m2) = DO.Mapping $ m1 ++ m2
# combineMappings _ _ = error "Data.Object is not a Mapping."
#
# loadHerokuConfig :: DO.TextObject -> IO Settings.PersistConfig
# loadHerokuConfig ymlenv = do
# #if DEVELOPMENT
# let urlMap = DO.Mapping []
# #else # #else
# dbConnParams env = do # urlMap <- Web.Heroku.dbConnParams >>= return . toMapping . map canonicalizeKey
# ... # #endif
# either error return $ Database.Persist.Base.loadConfig (combineMappings urlMap ymlenv)
# #
# #
# withYesodHeroku :: AppConfig DefaultEnv () -> Logger -> (Application -> IO ()) -> IO ()
# withYesodHeroku conf logger f = do
# s <- staticSite
# dbconf <- withYamlEnvironment "config/postgresql.yml" (appEnv conf) loadHerokuConfig
# Database.Persist.Base.withPool (dbconf :: Settings.PersistConfig) $ \p -> do
# Database.Persist.Base.runPool dbconf (runMigration migrateAll) p
# let h = YesodHeroku conf logger s p
# defaultRunner (f . logWare) h
# where
# #ifdef DEVELOPMENT
# logWare = logHandleDev (\msg -> logBS logger msg >> flushLogger logger)
# #else
# logWare = logStdout
# #endif
# Heroku setup: # Heroku setup:
# Find the Heroku guide. Roughly: # Find the Heroku guide. Roughly:
# #