From 62944018d8ac63ba33ac341dae5834cb4caf2d2d Mon Sep 17 00:00:00 2001 From: Sibi Prabakaran Date: Sat, 25 Aug 2018 22:12:31 +0530 Subject: [PATCH 1/7] Add dev flags to both the executables --- package.yaml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/package.yaml b/package.yaml index 115819b..aa612c5 100644 --- a/package.yaml +++ b/package.yaml @@ -147,6 +147,8 @@ executables: when: - condition: flag(library-only) buildable: false + - condition: flag(dev) + cpp-options: -DDEVELOPMENT stackage-server-cron: main: stackage-server-cron.hs @@ -161,3 +163,5 @@ executables: when: - condition: flag(library-only) buildable: false + - condition: flag(dev) + cpp-options: -DDEVELOPMENT From 9ea91909c20f584f778f08dc2577bfcc7bff1e36 Mon Sep 17 00:00:00 2001 From: Sibi Prabakaran Date: Sat, 25 Aug 2018 22:13:09 +0530 Subject: [PATCH 2/7] Add CPP flags --- src/Application.hs | 3 +++ src/Stackage/Database/Cron.hs | 3 +++ 2 files changed, 6 insertions(+) diff --git a/src/Application.hs b/src/Application.hs index 041f850..88c2c71 100644 --- a/src/Application.hs +++ b/src/Application.hs @@ -1,4 +1,5 @@ {-# OPTIONS_GHC -fno-warn-orphans #-} +{-# LANGUAGE CPP#-} module Application ( getApplicationDev , appMain @@ -81,7 +82,9 @@ makeApplication foundation = do appPlain <- toWaiAppPlain foundation let middleware = id -- prometheus def +#if !DEVELOPMENT . forceSSL' (appSettings foundation) +#endif . logWare . defaultMiddlewaresNoLogging diff --git a/src/Stackage/Database/Cron.hs b/src/Stackage/Database/Cron.hs index adafc4c..d2523b5 100644 --- a/src/Stackage/Database/Cron.hs +++ b/src/Stackage/Database/Cron.hs @@ -1,3 +1,4 @@ +{-# LANGUAGE CPP#-} module Stackage.Database.Cron ( stackageServerCron , newHoogleLocker @@ -107,6 +108,7 @@ stackageServerCron = do } createStackageDatabase dbfp +#if !DEVELOPMENT db <- openStackageDatabase dbfp do @@ -139,6 +141,7 @@ stackageServerCron = do let dest = unpack key createDirectoryIfMissing True $ takeDirectory dest renamePath fp dest +#endif createHoogleDB :: StackageDatabase -> Manager -> SnapName -> IO (Maybe FilePath) createHoogleDB db man name = handleAny (\e -> print e $> Nothing) $ do From 6498a6365e7bb4dba09b89f470ed4e33dea3bc29 Mon Sep 17 00:00:00 2001 From: Sibi Prabakaran Date: Sat, 25 Aug 2018 22:13:26 +0530 Subject: [PATCH 3/7] Update README --- README.md | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/README.md b/README.md index dc4dc65..6b04a84 100644 --- a/README.md +++ b/README.md @@ -7,3 +7,30 @@ Server for stable, curated Haskell package sets This repo is part of the [Stackage project](https://github.com/fpco/stackage), and the live server can be viewed at https://www.stackage.org. + +postgresql://[user[:password]@][netloc][:port][/dbname][?param1=value1&...] + +postgresql://postgres:password@localhost:5432/stackage + +## Building locally + +Build locally by passing the `dev` flag to it: + +``` shellsession +$ stack build . --flag stackage-server:dev +``` + +Now, initially you need to run the cron job and create and populate the database: + +``` shellsession +$ export PGSTRING=postgresql://postgres:password@localhost:5432/stackage +$ stack exec stackage-server-cron +``` + +After this, try running in the stackage server: + +``` shellsession +$ stack exec stackage-server +``` + + From d6e39d96b88f6ff619278e6682e17b37391ad0cf Mon Sep 17 00:00:00 2001 From: Sibi Prabakaran Date: Sat, 25 Aug 2018 22:14:40 +0530 Subject: [PATCH 4/7] Update README --- README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/README.md b/README.md index 6b04a84..d6fcb07 100644 --- a/README.md +++ b/README.md @@ -27,9 +27,12 @@ $ export PGSTRING=postgresql://postgres:password@localhost:5432/stackage $ stack exec stackage-server-cron ``` +Note that you need to modify the PGSTRING according to your actual database configuration. Also, you need to create an empty database before running the cron job. + After this, try running in the stackage server: ``` shellsession +$ export PGSTRING=postgresql://postgres:password@localhost:5432/stackage $ stack exec stackage-server ``` From 79a8cc7044d0447bd3d7b1ddbb22809f22196677 Mon Sep 17 00:00:00 2001 From: Sibi Prabakaran Date: Sat, 25 Aug 2018 23:42:52 +0530 Subject: [PATCH 5/7] Update README --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index d6fcb07..d6b887e 100644 --- a/README.md +++ b/README.md @@ -27,7 +27,7 @@ $ export PGSTRING=postgresql://postgres:password@localhost:5432/stackage $ stack exec stackage-server-cron ``` -Note that you need to modify the PGSTRING according to your actual database configuration. Also, you need to create an empty database before running the cron job. +Note that you need to modify the PGSTRING according to your actual database configuration. Also, you need to create an empty database before running the cron job. Note that it takes quites some time for it to load your database. After this, try running in the stackage server: From 709a19462108d001916b9a1b3a72141d02bbae53 Mon Sep 17 00:00:00 2001 From: Sibi Prabakaran Date: Sat, 25 Aug 2018 23:48:30 +0530 Subject: [PATCH 6/7] Cleanup --- README.md | 4 ---- 1 file changed, 4 deletions(-) diff --git a/README.md b/README.md index d6b887e..09fe2de 100644 --- a/README.md +++ b/README.md @@ -8,10 +8,6 @@ Server for stable, curated Haskell package sets This repo is part of the [Stackage project](https://github.com/fpco/stackage), and the live server can be viewed at https://www.stackage.org. -postgresql://[user[:password]@][netloc][:port][/dbname][?param1=value1&...] - -postgresql://postgres:password@localhost:5432/stackage - ## Building locally Build locally by passing the `dev` flag to it: From f037a18415a7d1036dd819b681db6e4ca27cdf33 Mon Sep 17 00:00:00 2001 From: Sibi Prabakaran Date: Sat, 25 Aug 2018 23:49:43 +0530 Subject: [PATCH 7/7] Make it more clear --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 09fe2de..c2c1abb 100644 --- a/README.md +++ b/README.md @@ -16,16 +16,16 @@ Build locally by passing the `dev` flag to it: $ stack build . --flag stackage-server:dev ``` -Now, initially you need to run the cron job and create and populate the database: +Now, initially you need to run the cron job to create and populate the database: ``` shellsession $ export PGSTRING=postgresql://postgres:password@localhost:5432/stackage $ stack exec stackage-server-cron ``` -Note that you need to modify the PGSTRING according to your actual database configuration. Also, you need to create an empty database before running the cron job. Note that it takes quites some time for it to load your database. +Note that you need to modify the PGSTRING environment variable according to your actual database configuration. Also, you need to create an empty database before running the cron job. Note that it takes quites some time for it to load your database. -After this, try running in the stackage server: +After this, run the stackage server: ``` shellsession $ export PGSTRING=postgresql://postgres:password@localhost:5432/stackage