mirror of
https://github.com/commercialhaskell/stackage-server.git
synced 2026-01-23 09:21:56 +01:00
Merge pull request #257 from psibi/local-installation
Support for local installation of stackage-server
This commit is contained in:
commit
e0661a0ada
26
README.md
26
README.md
@ -7,3 +7,29 @@ Server for stable, curated Haskell package sets
|
|||||||
|
|
||||||
This repo is part of the [Stackage project](https://github.com/fpco/stackage),
|
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.
|
and the live server can be viewed at https://www.stackage.org.
|
||||||
|
|
||||||
|
## 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 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 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, run the stackage server:
|
||||||
|
|
||||||
|
``` shellsession
|
||||||
|
$ export PGSTRING=postgresql://postgres:password@localhost:5432/stackage
|
||||||
|
$ stack exec stackage-server
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -147,6 +147,8 @@ executables:
|
|||||||
when:
|
when:
|
||||||
- condition: flag(library-only)
|
- condition: flag(library-only)
|
||||||
buildable: false
|
buildable: false
|
||||||
|
- condition: flag(dev)
|
||||||
|
cpp-options: -DDEVELOPMENT
|
||||||
|
|
||||||
stackage-server-cron:
|
stackage-server-cron:
|
||||||
main: stackage-server-cron.hs
|
main: stackage-server-cron.hs
|
||||||
@ -161,3 +163,5 @@ executables:
|
|||||||
when:
|
when:
|
||||||
- condition: flag(library-only)
|
- condition: flag(library-only)
|
||||||
buildable: false
|
buildable: false
|
||||||
|
- condition: flag(dev)
|
||||||
|
cpp-options: -DDEVELOPMENT
|
||||||
|
|||||||
@ -1,4 +1,5 @@
|
|||||||
{-# OPTIONS_GHC -fno-warn-orphans #-}
|
{-# OPTIONS_GHC -fno-warn-orphans #-}
|
||||||
|
{-# LANGUAGE CPP#-}
|
||||||
module Application
|
module Application
|
||||||
( getApplicationDev
|
( getApplicationDev
|
||||||
, appMain
|
, appMain
|
||||||
@ -81,7 +82,9 @@ makeApplication foundation = do
|
|||||||
appPlain <- toWaiAppPlain foundation
|
appPlain <- toWaiAppPlain foundation
|
||||||
|
|
||||||
let middleware = id -- prometheus def
|
let middleware = id -- prometheus def
|
||||||
|
#if !DEVELOPMENT
|
||||||
. forceSSL' (appSettings foundation)
|
. forceSSL' (appSettings foundation)
|
||||||
|
#endif
|
||||||
. logWare
|
. logWare
|
||||||
. defaultMiddlewaresNoLogging
|
. defaultMiddlewaresNoLogging
|
||||||
|
|
||||||
|
|||||||
@ -1,3 +1,4 @@
|
|||||||
|
{-# LANGUAGE CPP#-}
|
||||||
module Stackage.Database.Cron
|
module Stackage.Database.Cron
|
||||||
( stackageServerCron
|
( stackageServerCron
|
||||||
, newHoogleLocker
|
, newHoogleLocker
|
||||||
@ -107,6 +108,7 @@ stackageServerCron = do
|
|||||||
}
|
}
|
||||||
createStackageDatabase dbfp
|
createStackageDatabase dbfp
|
||||||
|
|
||||||
|
#if !DEVELOPMENT
|
||||||
db <- openStackageDatabase dbfp
|
db <- openStackageDatabase dbfp
|
||||||
|
|
||||||
do
|
do
|
||||||
@ -139,6 +141,7 @@ stackageServerCron = do
|
|||||||
let dest = unpack key
|
let dest = unpack key
|
||||||
createDirectoryIfMissing True $ takeDirectory dest
|
createDirectoryIfMissing True $ takeDirectory dest
|
||||||
renamePath fp dest
|
renamePath fp dest
|
||||||
|
#endif
|
||||||
|
|
||||||
createHoogleDB :: StackageDatabase -> Manager -> SnapName -> IO (Maybe FilePath)
|
createHoogleDB :: StackageDatabase -> Manager -> SnapName -> IO (Maybe FilePath)
|
||||||
createHoogleDB db man name = handleAny (\e -> print e $> Nothing) $ do
|
createHoogleDB db man name = handleAny (\e -> print e $> Nothing) $ do
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user