made web server not start background tasks.

This commit is contained in:
Bryce Covert
2020-12-08 21:24:26 -08:00
parent 99b6d822f6
commit 689cae6192
7 changed files with 110 additions and 20 deletions

View File

@@ -17,4 +17,6 @@
:yodlee-base-url "https://developer.api.yodlee.com/ysl" :yodlee-base-url "https://developer.api.yodlee.com/ysl"
:yodlee-app "10003600" :yodlee-app "10003600"
:yodlee-fastlink "https://node.developer.yodlee.com/authenticate/restserver/?channelAppName=restserver" :yodlee-fastlink "https://node.developer.yodlee.com/authenticate/restserver/?channelAppName=restserver"
:run-web? true
:run-background? true
} }

View File

@@ -15,4 +15,6 @@
:yodlee-fastlink "https://quickstartus2node.yodleeinteractive.com/authenticate/qstartus12/?channelAppName=quickstartus2" :yodlee-fastlink "https://quickstartus2node.yodleeinteractive.com/authenticate/qstartus12/?channelAppName=quickstartus2"
:yodlee-proxy-host "172.31.10.83" :yodlee-proxy-host "172.31.10.83"
:yodlee-proxy-port 8888 :yodlee-proxy-port 8888
:run-background? false
:run-web? true
} }

View File

@@ -15,4 +15,6 @@
:yodlee-fastlink "https://quickstartus2node.yodleeinteractive.com/authenticate/qstartus12/?channelAppName=quickstartus2" :yodlee-fastlink "https://quickstartus2node.yodleeinteractive.com/authenticate/qstartus12/?channelAppName=quickstartus2"
:yodlee-proxy-host "172.31.10.83" :yodlee-proxy-host "172.31.10.83"
:yodlee-proxy-port 8888 :yodlee-proxy-port 8888
:run-background? true
:run-web? true
} }

View File

@@ -1,12 +1,12 @@
(ns auto-ap.server (ns auto-ap.server
(:require #_[auto-ap.background.mail :refer [always-process-sqs]] (:require #_[auto-ap.background.mail :refer [always-process-sqs]]
[auto-ap.handler :refer [app]] [auto-ap.handler :refer [app]]
[auto-ap.ledger] [auto-ap.ledger :as ledger]
[auto-ap.yodlee.core] [auto-ap.yodlee.core]
[auto-ap.background.invoices] [auto-ap.background.invoices]
[auto-ap.square.core] [auto-ap.square.core :as square]
[auto-ap.datomic.migrate] [auto-ap.datomic.migrate :as migrate]
[auto-ap.yodlee.import] [auto-ap.yodlee.import :as yodlee]
[nrepl.server :refer [start-server stop-server]] [nrepl.server :refer [start-server stop-server]]
[config.core :refer [env]] [config.core :refer [env]]
[ring.adapter.jetty :refer [run-jetty]] [ring.adapter.jetty :refer [run-jetty]]
@@ -28,6 +28,16 @@
(mount/stop)) (mount/stop))
(defn -main [& args] (defn -main [& args]
(add-shutdown-hook! shutdown-mount) (let [without (cond-> #{}
(start-server :port 9000 :bind "0.0.0.0" #_#_:handler (cider-nrepl-handler)) (not (env :run-web? )) (into [#'jetty])
(mount/start)) (not (env :run-background?)) (into [#'square/square-loader
#'square/square-settlement-loader
#'ledger/touch-broken-ledger-worker
#'ledger/process-txes-worker
#'ledger/ledger-reconciliation-worker
#'yodlee/import-transaction-worker
#'migrate/migrate-start]))]
(add-shutdown-hook! shutdown-mount)
(start-server :port 9000 :bind "0.0.0.0" #_#_:handler (cider-nrepl-handler))
(mount/start-without without)))

View File

@@ -22,11 +22,24 @@ resource "aws_ecs_task_definition" "integreat_app" {
task_role_arn = "${var.task_role_arn}" task_role_arn = "${var.task_role_arn}"
} }
resource "aws_ecs_task_definition" "integreat_background_worker" {
family = "integreat_background-worker_${var.stage}"
container_definitions = file("${var.stage}-background-worker-taskdef.json")
memory = 2048
cpu = 1024
network_mode = "awsvpc"
requires_compatibilities = ["FARGATE"]
execution_role_arn = "${var.execution_role_arn}"
task_role_arn = "${var.task_role_arn}"
}
resource "aws_ecs_service" "integreat_app" { resource "aws_ecs_service" "integreat_app" {
name = "integreat_app_${var.stage}" name = "integreat_app_${var.stage}"
cluster = "${var.ecs_cluster}" cluster = "${var.ecs_cluster}"
task_definition = aws_ecs_task_definition.integreat_app.arn task_definition = aws_ecs_task_definition.integreat_app.arn
desired_count = 1 desired_count = 2
health_check_grace_period_seconds = 600 health_check_grace_period_seconds = 600
deployment_controller { deployment_controller {
type = "ECS" type = "ECS"
@@ -55,6 +68,33 @@ resource "aws_ecs_service" "integreat_app" {
timeouts {} timeouts {}
} }
resource "aws_ecs_service" "integreat_background_worker" {
name = "integreat_background_worker_${var.stage}"
cluster = "${var.ecs_cluster}"
task_definition = aws_ecs_task_definition.integreat_background_worker.arn
desired_count = 1
deployment_controller {
type = "ECS"
}
scheduling_strategy = "REPLICA"
launch_type = "FARGATE"
platform_version = "LATEST"
network_configuration {
assign_public_ip = true
security_groups = [ "sg-004e5855310c453a3", "sg-02d167406b1082698"]
subnets = [ "subnet-5e675761", "subnet-8519fde2", "subnet-89bab8d4" ]
}
service_registries {
container_port = 0
port = 0
registry_arn = aws_service_discovery_service.service.arn
}
timeouts {}
}
resource "aws_lb" "integreat_app" { resource "aws_lb" "integreat_app" {
name = "integreat-app-${var.stage}" name = "integreat-app-${var.stage}"
internal = false internal = false

View File

@@ -1,7 +1,7 @@
{ {
"version": 4, "version": 4,
"terraform_version": "0.13.3", "terraform_version": "0.13.3",
"serial": 72, "serial": 75,
"lineage": "9b630886-8cee-a57d-c7a2-4f19f13f9c51", "lineage": "9b630886-8cee-a57d-c7a2-4f19f13f9c51",
"outputs": { "outputs": {
"aws_access_key_id": { "aws_access_key_id": {
@@ -33,7 +33,7 @@
"attributes": { "attributes": {
"account_id": "679918342773", "account_id": "679918342773",
"arn": "arn:aws:iam::679918342773:user/bryce", "arn": "arn:aws:iam::679918342773:user/bryce",
"id": "2020-09-26 05:35:11.176798 +0000 UTC", "id": "2020-12-09 05:22:32.641901 +0000 UTC",
"user_id": "AIDAJPUJFTOKO4IRADMV4" "user_id": "AIDAJPUJFTOKO4IRADMV4"
} }
} }
@@ -180,6 +180,40 @@
"FARGATE" "FARGATE"
], ],
"revision": 4, "revision": 4,
"tags": {},
"task_role_arn": "arn:aws:iam::679918342773:role/datomic-ddb",
"volume": []
},
"private": "eyJzY2hlbWFfdmVyc2lvbiI6IjEifQ=="
}
]
},
{
"mode": "managed",
"type": "aws_ecs_task_definition",
"name": "integreat_background_worker",
"provider": "provider[\"registry.terraform.io/hashicorp/aws\"]",
"instances": [
{
"schema_version": 1,
"attributes": {
"arn": "arn:aws:ecs:us-east-1:679918342773:task-definition/integreat_background-worker_prod:1",
"container_definitions": "[{\"cpu\":0,\"environment\":[{\"name\":\"config\",\"value\":\"/usr/local/config/prod-background-worker.edn\"}],\"essential\":true,\"image\":\"679918342773.dkr.ecr.us-east-1.amazonaws.com/integreat\",\"logConfiguration\":{\"logDriver\":\"awslogs\",\"options\":{\"awslogs-group\":\"/ecs/integreat-app-prod\",\"awslogs-region\":\"us-east-1\",\"awslogs-stream-prefix\":\"ecs\"}},\"mountPoints\":[],\"name\":\"integreat-background-worker\",\"portMappings\":[{\"containerPort\":9000,\"hostPort\":9000,\"protocol\":\"tcp\"}],\"volumesFrom\":[]}]",
"cpu": "1024",
"execution_role_arn": "arn:aws:iam::679918342773:role/ecsTaskExecutionRole",
"family": "integreat_background-worker_prod",
"id": "integreat_background-worker_prod",
"inference_accelerator": [],
"ipc_mode": "",
"memory": "2048",
"network_mode": "awsvpc",
"pid_mode": "",
"placement_constraints": [],
"proxy_configuration": [],
"requires_compatibilities": [
"FARGATE"
],
"revision": 1,
"tags": null, "tags": null,
"task_role_arn": "arn:aws:iam::679918342773:role/datomic-ddb", "task_role_arn": "arn:aws:iam::679918342773:role/datomic-ddb",
"volume": [] "volume": []
@@ -509,8 +543,8 @@
"path": "/api/health-check", "path": "/api/health-check",
"port": "traffic-port", "port": "traffic-port",
"protocol": "HTTP", "protocol": "HTTP",
"timeout": 5, "timeout": 14,
"unhealthy_threshold": 2 "unhealthy_threshold": 5
} }
], ],
"id": "arn:aws:elasticloadbalancing:us-east-1:679918342773:targetgroup/integreat-app-prod/d5b51736182d8407", "id": "arn:aws:elasticloadbalancing:us-east-1:679918342773:targetgroup/integreat-app-prod/d5b51736182d8407",

View File

@@ -1,7 +1,7 @@
{ {
"version": 4, "version": 4,
"terraform_version": "0.13.3", "terraform_version": "0.13.3",
"serial": 68, "serial": 72,
"lineage": "9b630886-8cee-a57d-c7a2-4f19f13f9c51", "lineage": "9b630886-8cee-a57d-c7a2-4f19f13f9c51",
"outputs": { "outputs": {
"aws_access_key_id": { "aws_access_key_id": {
@@ -33,7 +33,7 @@
"attributes": { "attributes": {
"account_id": "679918342773", "account_id": "679918342773",
"arn": "arn:aws:iam::679918342773:user/bryce", "arn": "arn:aws:iam::679918342773:user/bryce",
"id": "2020-09-26 05:16:10.008633 +0000 UTC", "id": "2020-09-26 05:35:11.176798 +0000 UTC",
"user_id": "AIDAJPUJFTOKO4IRADMV4" "user_id": "AIDAJPUJFTOKO4IRADMV4"
} }
} }
@@ -139,8 +139,8 @@
"registry_arn": "arn:aws:servicediscovery:us-east-1:679918342773:service/srv-m232jsqnpvd5e2xb" "registry_arn": "arn:aws:servicediscovery:us-east-1:679918342773:service/srv-m232jsqnpvd5e2xb"
} }
], ],
"tags": null, "tags": {},
"task_definition": "arn:aws:ecs:us-east-1:679918342773:task-definition/integreat_app_prod:1", "task_definition": "arn:aws:ecs:us-east-1:679918342773:task-definition/integreat_app_prod:4",
"timeouts": { "timeouts": {
"delete": null "delete": null
} }
@@ -163,8 +163,8 @@
{ {
"schema_version": 1, "schema_version": 1,
"attributes": { "attributes": {
"arn": "arn:aws:ecs:us-east-1:679918342773:task-definition/integreat_app_prod:1", "arn": "arn:aws:ecs:us-east-1:679918342773:task-definition/integreat_app_prod:4",
"container_definitions": "[{\"cpu\":0,\"environment\":[{\"name\":\"config\",\"value\":\"/usr/local/config/prod.edn\"}],\"essential\":true,\"image\":\"679918342773.dkr.ecr.us-east-1.amazonaws.com/integreat\",\"logConfiguration\":{\"logDriver\":\"awslogs\",\"options\":{\"awslogs-group\":\"/ecs/integreat-app\",\"awslogs-region\":\"us-east-1\",\"awslogs-stream-prefix\":\"ecs\"}},\"mountPoints\":[],\"name\":\"integreat-app\",\"portMappings\":[{\"containerPort\":3000,\"hostPort\":3000,\"protocol\":\"tcp\"},{\"containerPort\":9000,\"hostPort\":9000,\"protocol\":\"tcp\"}],\"volumesFrom\":[]}]", "container_definitions": "[{\"cpu\":0,\"environment\":[{\"name\":\"config\",\"value\":\"/usr/local/config/prod.edn\"}],\"essential\":true,\"image\":\"679918342773.dkr.ecr.us-east-1.amazonaws.com/integreat\",\"logConfiguration\":{\"logDriver\":\"awslogs\",\"options\":{\"awslogs-group\":\"/ecs/integreat-app-prod\",\"awslogs-region\":\"us-east-1\",\"awslogs-stream-prefix\":\"ecs\"}},\"mountPoints\":[],\"name\":\"integreat-app\",\"portMappings\":[{\"containerPort\":3000,\"hostPort\":3000,\"protocol\":\"tcp\"},{\"containerPort\":9000,\"hostPort\":9000,\"protocol\":\"tcp\"}],\"volumesFrom\":[]}]",
"cpu": "2048", "cpu": "2048",
"execution_role_arn": "arn:aws:iam::679918342773:role/ecsTaskExecutionRole", "execution_role_arn": "arn:aws:iam::679918342773:role/ecsTaskExecutionRole",
"family": "integreat_app_prod", "family": "integreat_app_prod",
@@ -179,8 +179,8 @@
"requires_compatibilities": [ "requires_compatibilities": [
"FARGATE" "FARGATE"
], ],
"revision": 1, "revision": 4,
"tags": {}, "tags": null,
"task_role_arn": "arn:aws:iam::679918342773:role/datomic-ddb", "task_role_arn": "arn:aws:iam::679918342773:role/datomic-ddb",
"volume": [] "volume": []
}, },