Skip to content

Commit

Permalink
make web run through hacky janitor
Browse files Browse the repository at this point in the history
  • Loading branch information
jaspervdj committed Dec 13, 2023
1 parent 64e110e commit 8fe7d79
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 9 deletions.
5 changes: 5 additions & 0 deletions cabal.project
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,8 @@ source-repository-package
type: git
location: https://github.com/jaspervdj/urlencoded.git
tag: 79e31ed9279c820bb89e36824464fdfb4b7b968a

source-repository-package
type: git
location: https://github.com/jaspervdj/wai-handler-hal.git
tag: 999114f42a7a36e1486c3f723377b50a2e88c11d
6 changes: 3 additions & 3 deletions deploy/template.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,9 @@ Resources:
Type: 'AWS::Lambda::Function'
Properties:
FunctionName: 'zureg-web'
Handler: 'main.web_handler'
Handler: 'web'
Role: {'Fn::GetAtt': ['LambdaExecutionRole', 'Arn']}
Runtime: 'python3.9'
Runtime: 'provided'
Timeout: 10
MemorySize: 512 # If not, requests to DDB time out...
Code:
Expand Down Expand Up @@ -195,7 +195,7 @@ Resources:
Type: 'AWS::Lambda::Function'
Properties:
FunctionName: 'zureg-janitor'
Handler: 'NOT_USED'
Handler: 'janitor'
Role: {'Fn::GetAtt': ['LambdaExecutionRole', 'Arn']}
Runtime: 'provided'
Timeout: 10
Expand Down
1 change: 1 addition & 0 deletions lib/Zureg/Main/Web.hs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
{-# LANGUAGE TemplateHaskell #-}
module Zureg.Main.Web
( main
, app
) where

import Control.Applicative (liftA2)
Expand Down
17 changes: 13 additions & 4 deletions src/Janitor.hs
Original file line number Diff line number Diff line change
@@ -1,9 +1,18 @@
{-# LANGUAGE ScopedTypeVariables #-}
import AWS.Lambda.Runtime (mRuntime)
import qualified Data.Aeson as A
import AWS.Lambda.Runtime (mRuntime)
import qualified Data.Aeson as A
import qualified Network.Wai.Handler.Hal as WaiHandler
import System.Environment (lookupEnv)
import qualified Zureg.Hackathon
import qualified Zureg.Main.Janitor
import qualified Zureg.Main.Web as Web

main :: IO ()
main = mRuntime $ \(_ :: A.Value) ->
Zureg.Hackathon.withHackathonFromEnv Zureg.Main.Janitor.main
main = do
handler <- lookupEnv "_HANDLER"
case handler of
Just "janitor" -> mRuntime $ \(_ :: A.Value) ->
Zureg.Hackathon.withHackathonFromEnv Zureg.Main.Janitor.main
_ -> do
app <- Zureg.Hackathon.withHackathonFromEnv Web.app
mRuntime $ WaiHandler.run app
1 change: 1 addition & 0 deletions stack.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ extra-deps:
- 'hal-1.0.0.1'
- 'unliftio-core-0.1.2.0'
- 'urlencoded-0.5.0.0'
- 'wai-handler-hal-0.2.0.0'
nix:
packages:
- 'zlib'
7 changes: 7 additions & 0 deletions stack.yaml.lock
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,13 @@ packages:
sha256: dc94e84bac66430bca207639fc8a2f1a37a88834c8f6572a0345f70298d6d0d1
original:
hackage: urlencoded-0.5.0.0
- completed:
hackage: wai-handler-hal-0.2.0.0@sha256:ef98b78c3beb05eecc9239775dd010308ed7a75b76a0db8471d4466a76b450f8,2954
pantry-tree:
size: 592
sha256: e500f789cb7b0dab089768a512e7703ad93407a73635a3cf1aa1081233c04ba5
original:
hackage: wai-handler-hal-0.2.0.0
snapshots:
- completed:
size: 586286
Expand Down
6 changes: 4 additions & 2 deletions zureg.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,6 @@ Library
eventful-dynamodb >= 0.2 && < 0.3,
file-embed >= 0.0 && < 0.1,
filepath >= 1.4 && < 1.5,
hal >= 1.0 && < 1.1,
http-client >= 0.5 && < 0.7,
http-client-tls >= 0.3 && < 0.4,
http-types >= 0.12 && < 0.13,
Expand Down Expand Up @@ -148,4 +147,7 @@ Executable zureg-badges
Executable zureg-janitor-lambda
Import: exe
Main-is: Janitor.hs
Build-depends: aeson, hal
Build-depends:
aeson >= 1.3 && < 1.6,
hal >= 1.0 && < 1.1,
wai-handler-hal >= 0.2 && < 0.3

0 comments on commit 8fe7d79

Please sign in to comment.