mirror of
https://github.com/commercialhaskell/stackage-server.git
synced 2026-01-29 20:30:25 +01:00
Disable cabal loader in production (want a separate batch job)
This commit is contained in:
parent
718a42701d
commit
0f4ba8595b
@ -33,6 +33,8 @@ import Yesod.Core.Types (loggerSet, Logger (Logger))
|
|||||||
import Yesod.Default.Config
|
import Yesod.Default.Config
|
||||||
import Yesod.Default.Handlers
|
import Yesod.Default.Handlers
|
||||||
import Yesod.Default.Main
|
import Yesod.Default.Main
|
||||||
|
import System.Environment (getEnvironment)
|
||||||
|
import Data.BlobStore (HasBlobStore)
|
||||||
|
|
||||||
import qualified Echo
|
import qualified Echo
|
||||||
|
|
||||||
@ -166,6 +168,12 @@ makeFoundation useEcho conf = do
|
|||||||
(Database.Persist.runPool dbconf (runMigration migrateAll) p)
|
(Database.Persist.runPool dbconf (runMigration migrateAll) p)
|
||||||
(messageLoggerSource foundation logger)
|
(messageLoggerSource foundation logger)
|
||||||
|
|
||||||
|
env <- getEnvironment
|
||||||
|
let loadCabalFiles' =
|
||||||
|
case lookup "STACKAGE_CABAL_LOADER" env of
|
||||||
|
Just "0" -> return ()
|
||||||
|
_ -> appLoadCabalFiles foundation dbconf p
|
||||||
|
|
||||||
-- Start the cabal file loader
|
-- Start the cabal file loader
|
||||||
ifRunCabalLoader $ forkIO $ forever $ flip runLoggingT (messageLoggerSource foundation logger) $ do
|
ifRunCabalLoader $ forkIO $ forever $ flip runLoggingT (messageLoggerSource foundation logger) $ do
|
||||||
$logInfoS "CLEANUP" "Cleaning up /tmp"
|
$logInfoS "CLEANUP" "Cleaning up /tmp"
|
||||||
@ -173,10 +181,29 @@ makeFoundation useEcho conf = do
|
|||||||
runResourceT $ sourceDirectory "/tmp" $$ mapM_C (cleanupTemp now)
|
runResourceT $ sourceDirectory "/tmp" $$ mapM_C (cleanupTemp now)
|
||||||
$logInfoS "CLEANUP" "Cleaning up complete"
|
$logInfoS "CLEANUP" "Cleaning up complete"
|
||||||
|
|
||||||
--when development $ liftIO $ threadDelay $ 5 * 60 * 1000000
|
loadCabalFiles'
|
||||||
eres <- tryAny $ flip runReaderT foundation $ do
|
|
||||||
let runDB' :: SqlPersistT (ResourceT (ReaderT App (LoggingT IO))) a
|
liftIO $ threadDelay $ 30 * 60 * 1000000
|
||||||
-> ReaderT App (LoggingT IO) a
|
return foundation
|
||||||
|
where ifRunCabalLoader m =
|
||||||
|
if cabalFileLoader
|
||||||
|
then void m
|
||||||
|
else return ()
|
||||||
|
|
||||||
|
appLoadCabalFiles :: ( PersistConfig c
|
||||||
|
, PersistConfigBackend c ~ SqlPersistT
|
||||||
|
, HasHackageRoot env
|
||||||
|
, HasBlobStore env StoreKey
|
||||||
|
, HasHttpManager env
|
||||||
|
)
|
||||||
|
=> env
|
||||||
|
-> c
|
||||||
|
-> PersistConfigPool c
|
||||||
|
-> LoggingT IO ()
|
||||||
|
appLoadCabalFiles env dbconf p = do
|
||||||
|
eres <- tryAny $ flip runReaderT env $ do
|
||||||
|
let runDB' :: SqlPersistT (ResourceT (ReaderT env (LoggingT IO))) a
|
||||||
|
-> ReaderT env (LoggingT IO) a
|
||||||
runDB' = runResourceT . flip (Database.Persist.runPool dbconf) p
|
runDB' = runResourceT . flip (Database.Persist.runPool dbconf) p
|
||||||
uploadHistory0 <- runDB' $ selectSource [] [] $$ sinkUploadHistory
|
uploadHistory0 <- runDB' $ selectSource [] [] $$ sinkUploadHistory
|
||||||
let toMDPair (E.Value name, E.Value version, E.Value hash') =
|
let toMDPair (E.Value name, E.Value version, E.Value hash') =
|
||||||
@ -205,12 +232,6 @@ makeFoundation useEcho conf = do
|
|||||||
case eres of
|
case eres of
|
||||||
Left e -> $logError $ tshow e
|
Left e -> $logError $ tshow e
|
||||||
Right () -> return ()
|
Right () -> return ()
|
||||||
liftIO $ threadDelay $ 30 * 60 * 1000000
|
|
||||||
return foundation
|
|
||||||
where ifRunCabalLoader m =
|
|
||||||
if cabalFileLoader
|
|
||||||
then void m
|
|
||||||
else return ()
|
|
||||||
|
|
||||||
cleanupTemp :: UTCTime -> FilePath -> ResourceT (LoggingT IO) ()
|
cleanupTemp :: UTCTime -> FilePath -> ResourceT (LoggingT IO) ()
|
||||||
cleanupTemp now fp
|
cleanupTemp now fp
|
||||||
|
|||||||
@ -1,6 +1,8 @@
|
|||||||
exec: ../dist/build/stackage-server/stackage-server
|
exec: ../dist/build/stackage-server/stackage-server
|
||||||
args:
|
args:
|
||||||
- production
|
- production
|
||||||
|
env:
|
||||||
|
STACKAGE_CABAL_LOADER: 0
|
||||||
host: www.stackage.org
|
host: www.stackage.org
|
||||||
|
|
||||||
redirects:
|
redirects:
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user