Makes logging unified
This commit is contained in:
@@ -2,26 +2,26 @@
|
||||
(:require [auto-ap.utils :refer [heartbeat]]
|
||||
[mount.core :as mount]
|
||||
[auto-ap.datomic :refer [conn ]]
|
||||
[clojure.tools.logging :as log]
|
||||
[auto-ap.logging :as alog]
|
||||
[nrepl.server :refer [start-server]]
|
||||
[auto-ap.background.metrics :refer [metrics-setup container-tags container-data logging-context]]
|
||||
[unilog.context :as lc]
|
||||
[com.brunobonacci.mulog :as mu]))
|
||||
|
||||
(defn execute [name f]
|
||||
(try
|
||||
(lc/with-context {:background-job name}
|
||||
(mu/with-context {:background-job name
|
||||
:service name}
|
||||
(mount/start (mount/only #{#'conn #'metrics-setup #'container-tags #'logging-context #'container-data }))
|
||||
(start-server :port 9000 :bind "0.0.0.0" #_#_:handler (cider-nrepl-handler))
|
||||
((heartbeat f name))
|
||||
(log/info "Stopping " name)
|
||||
(Thread/sleep 15000)
|
||||
(mount/stop)))
|
||||
(catch Exception e
|
||||
(log/error "ERROR" e)
|
||||
(println e)
|
||||
(throw e))
|
||||
(finally
|
||||
(System/exit 0))))
|
||||
(mu/with-context {:background-job name
|
||||
:source name
|
||||
:service name}
|
||||
(mu/trace ::execute-background-job
|
||||
[]
|
||||
(try
|
||||
(mount/start (mount/only #{#'conn #'metrics-setup #'container-tags #'logging-context #'container-data }))
|
||||
(start-server :port 9000 :bind "0.0.0.0" #_#_:handler (cider-nrepl-handler))
|
||||
((heartbeat f name))
|
||||
(alog/info ::stopping :job name)
|
||||
(Thread/sleep 15000)
|
||||
(mount/stop)
|
||||
(catch Exception e
|
||||
(alog/error ::job-error :error e)
|
||||
(throw e))
|
||||
(finally
|
||||
(System/exit 0))))))
|
||||
|
||||
Reference in New Issue
Block a user