(ns auto-ap.server
  (:require #_[auto-ap.background.mail :refer [always-process-sqs]]
            [auto-ap.handler :refer [app]]
            [clojure.tools.nrepl.server :refer [start-server stop-server]]
            [config.core :refer [env]]
            [ring.adapter.jetty :refer [run-jetty]])
  (:gen-class))

(defn cider-nrepl-handler []
  (require 'cider.nrepl)
  (ns-resolve 'cider.nrepl 'cider-nrepl-handler))

 (defn -main [& args]
   (start-server :port 9000 :bind "0.0.0.0" :handler (cider-nrepl-handler))
   (let [port (Integer/parseInt (or (env :port) "3000"))]
     #_(future (always-process-sqs))
     (run-jetty app {:port port :join? false})))
