start slowly

This commit is contained in:
nek0 2020-05-10 07:28:17 +02:00
parent fafa684da4
commit 583316224c
3 changed files with 34 additions and 20 deletions

View file

@ -5,6 +5,8 @@
{-# LANGUAGE FlexibleContexts #-}
module Main where
import Prelude as P
import Servant
import Servant.Server.Experimental.Auth
@ -21,6 +23,8 @@ import qualified Data.CaseInsensitive as CI
import Data.IP
import Database.PostgreSQL.Simple
import Database.PostgreSQL.Simple.Migration
import Database.PostgreSQL.Simple.Util
import Network.Wai
import Network.Wai.Logger
@ -81,17 +85,24 @@ main = do
"password='" <> fromString (T.unpack db_passwd) <> "'"
)
store <- newTVarIO S.empty
tracker <- newTVarIO M.empty
void $ execute_ conn initAvatar
void $ execute_ conn initUser
void $ execute_ conn initProduct
void $ execute_ conn initToken
void $ execute_ conn initAuthData
void $ execute_ conn initAmount
void $ execute_ conn initJournal
void $ execute_ conn initRole
void $ execute_ conn initUserToRole
-- tracker <- newTVarIO M.empty
migrationsExist <- existsTable conn "schema_migrations"
when (not migrationsExist) $ do
withTransaction conn $
void $ do
runMigration $
MigrationContext MigrationInitialization True conn
execute_ conn initAvatar
execute_ conn initUser
execute_ conn initProduct
execute_ conn initToken
execute_ conn initAuthData
execute_ conn initAmount
execute_ conn initJournal
execute_ conn initRole
execute_ conn initUserToRole
runInsertInitialRole
-- TODO: check for Migrations
forkCleanProcess conn store
withStdoutLogger $ \ilog -> do
let settings = setPort (fromIntegral lport) $

View file

@ -34,6 +34,7 @@ executable mateamt
, mtl
, opaleye
, postgresql-simple
, postgresql-simple-migration
, stm
, network
, servant

View file

@ -5,12 +5,13 @@ let
inherit (nixpkgs) pkgs;
f = { mkDerivation, aeson, base, base16-bytestring
, base64-bytestring, bytestring, case-insensitive, containers
, HsYAML, http-api-data, http-types, iproute, mtl, network, opaleye
, optparse-applicative, postgresql-simple, product-profunctors
, profunctors, pureMD5, random-bytestring, servant, servant-rawm
, servant-server, stdenv, stm, text, time, wai, wai-logger
, wai-middleware-throttle, warp
, base64-bytestring, bytestring, case-insensitive, clock
, containers, HsYAML, http-api-data, http-types, iproute, mtl
, network, opaleye, optparse-applicative, postgresql-simple
, postgresql-simple-migration, product-profunctors, profunctors
, pureMD5, random-bytestring, servant, servant-rawm, servant-server
, stdenv, stm, text, time, wai, wai-logger, wai-middleware-throttle
, warp
}:
mkDerivation {
pname = "mateamt";
@ -25,10 +26,11 @@ let
servant-rawm servant-server stm text time wai wai-logger warp
];
executableHaskellDepends = [
base base16-bytestring bytestring case-insensitive containers
base base16-bytestring bytestring case-insensitive clock containers
HsYAML iproute mtl network opaleye optparse-applicative
postgresql-simple servant servant-server stm text time wai
wai-logger wai-middleware-throttle warp
postgresql-simple postgresql-simple-migration servant
servant-server stm text time wai wai-logger wai-middleware-throttle
warp
];
description = "A whole new matemat";
license = stdenv.lib.licenses.agpl3;