diff --git a/src/clj/commiteth/routes/webhooks.clj b/src/clj/commiteth/routes/webhooks.clj index 123fba8..b7334fe 100644 --- a/src/clj/commiteth/routes/webhooks.clj +++ b/src/clj/commiteth/routes/webhooks.clj @@ -12,7 +12,7 @@ [commiteth.util.digest :refer [hex-hmac-sha1]] [compojure.core :refer [defroutes POST]] [crypto.equality :as crypto] - [ring.util.http-response :refer [ok]] + [ring.util.http-response :refer [ok forbidden]] [commiteth.db.bounties :as bounties-db]) (:import java.lang.Integer)) @@ -194,8 +194,10 @@ (defroutes webhook-routes (POST "/webhook" {:keys [headers body]} + (log/debug "webhook POST, headers" headers) (let [raw-payload (slurp body) payload (json/parse-string raw-payload true)] + (log/debug "webhook POST, payload" payload) (if (validate-secret payload raw-payload (get headers "x-hub-signature")) (do (log/debug "Github secret validation OK") @@ -203,4 +205,5 @@ (case (get headers "x-github-event") "issues" (handle-issue payload) "pull_request" (handle-pull-request payload) - (ok))))))) + (ok))) + (forbidden))))) diff --git a/src/clj/commiteth/scheduler.clj b/src/clj/commiteth/scheduler.clj index 188404f..02a7c0b 100644 --- a/src/clj/commiteth/scheduler.clj +++ b/src/clj/commiteth/scheduler.clj @@ -134,14 +134,19 @@ (update-confirm-hash) (update-payout-receipt) (self-sign-bounty) - (update-balances))) + (update-balances) + (log/debug "run-periodic-tasks done"))) (mount/defstate scheduler :start (let [every-minute (rest (periodic-seq (t/now) (-> 1 t/minutes))) - stop-fn (chime-at every-minute run-periodic-tasks)] + stop-fn (chime-at every-minute + run-periodic-tasks + {:error-handler (fn [e] + (log/error "Scheduled task failed" e) + (throw e))})] (log/info "started scheduler") stop-fn) :stop (do