splitting out background tasks

This commit is contained in:
2022-09-18 06:51:27 -07:00
parent 5017d9bc67
commit d65c87dc6d
5 changed files with 161 additions and 0 deletions

View File

@@ -0,0 +1,21 @@
(ns auto-ap.jobs.ledger-reconcile
(:gen-class)
(:require [auto-ap.ledger :as ledger]
[auto-ap.utils :refer [heartbeat]]
[mount.core :as mount]
[auto-ap.datomic :refer [conn]]
[clojure.tools.logging :as log]
[auto-ap.background.metrics :refer [metrics-setup container-tags container-data logging-context]]
[unilog.context :as lc]))
(defn -main [& _]
(try
(lc/with-context {:background-job "reconcile-ledger"}
(mount/start (mount/only #{#'conn #'metrics-setup #'container-tags #'logging-context #'container-data}))
((heartbeat ledger/reconcile-ledger "reconcile-ledger"))
((heartbeat ledger/touch-broken-ledger "touch-broken-ledger"))
(mount/stop)
(log/info "Stopping Ledger reconciliation"))
(finally
(System/exit 0))))