Makes new job for Brian
This commit is contained in:
@@ -8,7 +8,8 @@
|
|||||||
[clojure.string :as str]
|
[clojure.string :as str]
|
||||||
[config.core :refer [env]]
|
[config.core :refer [env]]
|
||||||
[clojure.tools.logging :as log]
|
[clojure.tools.logging :as log]
|
||||||
[com.walmartlabs.lacinia.util :refer [attach-resolvers]])
|
[com.walmartlabs.lacinia.util :refer [attach-resolvers]]
|
||||||
|
[clojure.edn :as edn])
|
||||||
(:import
|
(:import
|
||||||
(com.amazonaws.services.ecs.model AssignPublicIp)))
|
(com.amazonaws.services.ecs.model AssignPublicIp)))
|
||||||
|
|
||||||
@@ -80,21 +81,23 @@
|
|||||||
(map :name)
|
(map :name)
|
||||||
set))
|
set))
|
||||||
|
|
||||||
(defn run-task [task]
|
(defn run-task [task args]
|
||||||
(log/info "running job" task)
|
(log/info "running job" task)
|
||||||
(ecs/run-task :capacity-provider-strategy [{:base 1 :weight 1 :capacity-provider "FARGATE_SPOT"}]
|
(ecs/run-task (cond-> {:capacity-provider-strategy [{:base 1 :weight 1 :capacity-provider "FARGATE_SPOT"}]
|
||||||
:count 1
|
:count 1
|
||||||
:cluster "default"
|
:cluster "default"
|
||||||
:enable-ecs-managed-tags true
|
:enable-ecs-managed-tags true
|
||||||
:task-definition task
|
:task-definition task
|
||||||
:network-configuration {:aws-vpc-configuration {:subnets ["subnet-5e675761" "subnet-8519fde2" "subnet-89bab8d4"]
|
:network-configuration {:aws-vpc-configuration {:subnets ["subnet-5e675761" "subnet-8519fde2" "subnet-89bab8d4"]
|
||||||
:security-groups ["sg-004e5855310c453a3" "sg-02d167406b1082698"]
|
:security-groups ["sg-004e5855310c453a3" "sg-02d167406b1082698"]
|
||||||
:assign-public-ip AssignPublicIp/ENABLED}}))
|
:assign-public-ip AssignPublicIp/ENABLED}}}
|
||||||
|
args (assoc-in [:overrides :container-overrides ] [{:name "integreat-app" :environment [{:name "args" :value (pr-str task)}]}]))))
|
||||||
|
|
||||||
(defn request-job [context value _]
|
(defn request-job [context value _]
|
||||||
(assert-admin (:id context))
|
(assert-admin (:id context))
|
||||||
(if (not (get (currently-running-jobs) (:which value)))
|
(if (not (get (currently-running-jobs) (:which value)))
|
||||||
(let [new-job (run-task (str (str/replace (:which value) #"-" "_") "_" (:dd-env env)))]
|
(let [new-job (run-task (str (str/replace (:which value) #"-" "_") "_" (:dd-env env))
|
||||||
|
(some-> (:args value) edn/read-string))]
|
||||||
{:message (str "task " (str new-job) " started.")})
|
{:message (str "task " (str new-job) " started.")})
|
||||||
(assert-failure "This job is already running")))
|
(assert-failure "This job is already running")))
|
||||||
|
|
||||||
|
|||||||
13
src/clj/auto_ap/jobs/bulk_journal_import.clj
Normal file
13
src/clj/auto_ap/jobs/bulk_journal_import.clj
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
(ns auto-ap.jobs.bulk-journal-import
|
||||||
|
(:gen-class)
|
||||||
|
(:require
|
||||||
|
[auto-ap.jobs.core :refer [execute]]
|
||||||
|
[clojure.tools.logging :as log]
|
||||||
|
[config.core :refer [env]]))
|
||||||
|
|
||||||
|
(defn bulk-journal-import []
|
||||||
|
(log/info "importing ledger from" (:args env)))
|
||||||
|
|
||||||
|
(defn -main [& _]
|
||||||
|
(execute "bulk-journal-import" bulk-journal-import))
|
||||||
|
|
||||||
@@ -1,7 +1,6 @@
|
|||||||
(ns auto-ap.server
|
(ns auto-ap.server
|
||||||
(:gen-class)
|
(:gen-class)
|
||||||
(:require
|
(:require
|
||||||
[auto-ap.datomic.migrate :as migrate]
|
|
||||||
[auto-ap.handler :refer [app]]
|
[auto-ap.handler :refer [app]]
|
||||||
[auto-ap.jobs.close-auto-invoices :as job-close-auto-invoices]
|
[auto-ap.jobs.close-auto-invoices :as job-close-auto-invoices]
|
||||||
[auto-ap.jobs.current-balance-cache :as job-current-balance-cache]
|
[auto-ap.jobs.current-balance-cache :as job-current-balance-cache]
|
||||||
@@ -11,6 +10,7 @@
|
|||||||
[auto-ap.jobs.plaid :as job-plaid]
|
[auto-ap.jobs.plaid :as job-plaid]
|
||||||
[auto-ap.jobs.square :as job-square]
|
[auto-ap.jobs.square :as job-square]
|
||||||
[auto-ap.jobs.square2 :as job-square2]
|
[auto-ap.jobs.square2 :as job-square2]
|
||||||
|
[auto-ap.jobs.bulk-journal-import :as job-bulk-journal-import]
|
||||||
[auto-ap.jobs.sysco :as job-sysco]
|
[auto-ap.jobs.sysco :as job-sysco]
|
||||||
[auto-ap.jobs.vendor-usages :as job-vendor-usages]
|
[auto-ap.jobs.vendor-usages :as job-vendor-usages]
|
||||||
[auto-ap.jobs.yodlee2 :as job-yodlee2]
|
[auto-ap.jobs.yodlee2 :as job-yodlee2]
|
||||||
@@ -121,6 +121,9 @@
|
|||||||
(= job "close-auto-invoices")
|
(= job "close-auto-invoices")
|
||||||
(job-close-auto-invoices/-main)
|
(job-close-auto-invoices/-main)
|
||||||
|
|
||||||
|
(= job "bulk-journal-import")
|
||||||
|
(job-bulk-journal-import/-main)
|
||||||
|
|
||||||
:else
|
:else
|
||||||
|
|
||||||
(do
|
(do
|
||||||
|
|||||||
@@ -61,25 +61,20 @@
|
|||||||
:query-obj
|
:query-obj
|
||||||
{:venia/operation {:operation/type :mutation
|
{:venia/operation {:operation/type :mutation
|
||||||
:operation/name "RequestJob"}
|
:operation/name "RequestJob"}
|
||||||
:venia/variables [{:variable/name "args"
|
|
||||||
:variable/type :String
|
|
||||||
:variable/default (when (= which :bulk-journal-import)
|
|
||||||
(str/replace (pr-str (:data form))
|
|
||||||
"\"" "\\\""))}]
|
|
||||||
:venia/queries [{:query/data
|
:venia/queries [{:query/data
|
||||||
[:request-job
|
[:request-job
|
||||||
{:which (name which)
|
{:which (name which)
|
||||||
:args :$args}
|
:args (when (= which :bulk-journal-import)
|
||||||
|
(str/escape (pr-str (:data form)) {\" "\\\""}))}
|
||||||
[:message]]}]}
|
[:message]]}]}
|
||||||
:on-success [::success]}}))
|
:on-success [::success]}}))
|
||||||
|
|
||||||
|
|
||||||
(re-frame/reg-event-fx
|
(re-frame/reg-event-fx
|
||||||
::mounted
|
::mounted
|
||||||
(fn [_]
|
(fn [_]
|
||||||
{::track/register {:id ::params
|
{::track/register {:id ::params
|
||||||
:subscription [::data-page/params ::page]
|
:subscription [::data-page/params ::page]
|
||||||
:event-fn (fn [params]
|
:event-fn (fn [params]
|
||||||
[::params-change params])}}))
|
[::params-change params])}}))
|
||||||
|
|
||||||
(re-frame/reg-event-fx
|
(re-frame/reg-event-fx
|
||||||
|
|||||||
@@ -388,7 +388,7 @@ module "sysco_job" {
|
|||||||
ecs_cluster = var.ecs_cluster
|
ecs_cluster = var.ecs_cluster
|
||||||
task_role_arn = var.task_role_arn
|
task_role_arn = var.task_role_arn
|
||||||
stage = var.stage
|
stage = var.stage
|
||||||
schedule = "rate(1 hour)"
|
schedule = "rate(3 hours)"
|
||||||
job_name = "sysco"
|
job_name = "sysco"
|
||||||
execution_role_arn = var.execution_role_arn
|
execution_role_arn = var.execution_role_arn
|
||||||
memory = 2048
|
memory = 2048
|
||||||
@@ -418,3 +418,16 @@ module "yodlee2_accounts_job" {
|
|||||||
memory = 2048
|
memory = 2048
|
||||||
cpu = 512
|
cpu = 512
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
module "bulk_journal_import_job" {
|
||||||
|
source = "./background-job/"
|
||||||
|
ecs_cluster = var.ecs_cluster
|
||||||
|
task_role_arn = var.task_role_arn
|
||||||
|
stage = var.stage
|
||||||
|
job_name = "bulk-journal-import"
|
||||||
|
execution_role_arn = var.execution_role_arn
|
||||||
|
use_schedule = false
|
||||||
|
memory = 4096
|
||||||
|
cpu = 1024
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user