diff --git a/src/clj/auto_ap/graphql/clients.clj b/src/clj/auto_ap/graphql/clients.clj index 134efda2..bd1dc34f 100644 --- a/src/clj/auto_ap/graphql/clients.clj +++ b/src/clj/auto_ap/graphql/clients.clj @@ -16,7 +16,6 @@ [datomic.api :as d] [mount.core :as mount] [unilog.context :as lc] - [yang.scheduler :as scheduler] [clojure.set :as set]) (:import (java.util UUID) @@ -264,10 +263,6 @@ (defn refresh-current-balance [] (build-current-balance (bank-accounts-needing-refresh))) -(mount/defstate current-balance-worker - :start (scheduler/every (* 17 60 1000) (heartbeat refresh-current-balance "current-balance-cache")) - :stop (scheduler/stop current-balance-worker)) - (defn get-client [context _ _] (->graphql (->> (d-clients/get-all) diff --git a/src/clj/auto_ap/ledger.clj b/src/clj/auto_ap/ledger.clj index 39ddf05b..7d31de53 100644 --- a/src/clj/auto_ap/ledger.clj +++ b/src/clj/auto_ap/ledger.clj @@ -222,12 +222,6 @@ (log/warn "repairing " (count txes-missing-ledger-entries) " missing transactions, " (count invoices-missing-ledger-entries) " missing invoices that were missing ledger entries") @(d/transact conn repairs))))) -(mount/defstate reconciliation-frequency :start (* 1000 60 60)) - -(mount/defstate ledger-reconciliation-worker - :start (scheduler/every reconciliation-frequency (heartbeat reconcile-ledger "reconcile-ledger")) - :stop (scheduler/stop ledger-reconciliation-worker)) - (defn touch-transaction [e] @(d/transact conn [[:db/retractEntity [:journal-entry/original-entity e]]]) @@ -465,7 +459,3 @@ :text "This process looks for unbalance ledger entries, or missing ledger entries" :priority :low} nil)) - -(mount/defstate touch-broken-ledger-worker - :start (scheduler/every reconciliation-frequency (heartbeat touch-broken-ledger "touch-broken-ledger")) - :stop (scheduler/stop touch-broken-ledger-worker)) diff --git a/src/clj/auto_ap/server.clj b/src/clj/auto_ap/server.clj index 24f19f03..c9f8e1c3 100644 --- a/src/clj/auto_ap/server.clj +++ b/src/clj/auto_ap/server.clj @@ -16,6 +16,8 @@ [auto-ap.background.metrics :as metrics] [auto-ap.background.mail :as mail] [auto-ap.jobs.square :as job-square] + [auto-ap.jobs.ledger-reconcile :as job-reconcile-ledger] + [auto-ap.jobs.current-balance-cache :as job-current-balance-cache] [clojure.tools.logging :as log] [config.core :refer [env]] [mount.core :as mount] @@ -91,6 +93,13 @@ (cond (= job "square-import-job") (job-square/-main) + + (= job "reconcile-ledger") + (job-reconcile-ledger/-main) + + (= job "current-balance-cache") + (job-current-balance-cache/-main) + (= job "hello-world") (do (log/info "HELLO WORLD") @@ -104,14 +113,11 @@ (not (env :run-web? )) (into [#'jetty #'jetty-stats]) (not (env :run-background?)) (into [#'vendor/refresh-vendor-usages-worker - #'ledger/touch-broken-ledger-worker #'mail/import-invoices #'ledger/process-txes-worker - #'ledger/ledger-reconciliation-worker #'requests/request-listener #'sysco/sysco-invoice-importer #'auto-ap.background.invoices/close-auto-invoices-worker - #'gq-clients/current-balance-worker #'yodlee2/import-worker #'yodlee2/account-worker #'intuit/import-worker diff --git a/terraform/deploy.tf b/terraform/deploy.tf index 37c51fd9..1db388a7 100644 --- a/terraform/deploy.tf +++ b/terraform/deploy.tf @@ -324,42 +324,12 @@ resource "aws_service_discovery_service" "background_worker_service" { } } -resource "aws_cloudwatch_event_rule" "square_import_job_schedule" { - name = "square-import-job-schedule" - schedule_expression = "cron(45 * * * ? *)" -} - - - -resource "aws_cloudwatch_event_target" "square_import_job_target" { - target_id = "square-import-job" - arn = var.ecs_cluster - rule = aws_cloudwatch_event_rule.square_import_job_schedule.name - role_arn = "arn:aws:iam::679918342773:role/service-role/Amazon_EventBridge_Invoke_ECS_1758992733" - - ecs_target { - task_count = 1 - launch_type = "FARGATE" - - # capacity_provider_strategy = [{capacity_provider = "FARGATE_SPOT"}] - task_definition_arn = aws_ecs_task_definition.integreat_background_worker.arn - network_configuration { - assign_public_ip = true - security_groups = [ "sg-004e5855310c453a3", "sg-02d167406b1082698"] - subnets = [ "subnet-5e675761", "subnet-8519fde2", "subnet-89bab8d4" ] - } - } - - input = <