diff --git a/libs/kit-nrepl/deps.edn b/libs/kit-nrepl/deps.edn index c8f22ae..ea35f47 100644 --- a/libs/kit-nrepl/deps.edn +++ b/libs/kit-nrepl/deps.edn @@ -1,4 +1,5 @@ {:paths ["src"] :deps {org.clojure/tools.logging {:mvn/version "1.2.4"} integrant/integrant {:mvn/version "0.8.1"} - nrepl/nrepl {:mvn/version "1.0.0"}}} + nrepl/nrepl {:mvn/version "1.0.0"} + io.github.kit-clj/kit-core {:mvn/version "1.0.4"}}} diff --git a/libs/kit-nrepl/src/kit/edge/utils/nrepl.clj b/libs/kit-nrepl/src/kit/edge/utils/nrepl.clj index edbf273..9420f34 100644 --- a/libs/kit-nrepl/src/kit/edge/utils/nrepl.clj +++ b/libs/kit-nrepl/src/kit/edge/utils/nrepl.clj @@ -2,21 +2,31 @@ (:require [clojure.tools.logging :as log] [integrant.core :as ig] + [kit.ig-utils :as ig-utils] + [nrepl.cmdline] [nrepl.server :as nrepl])) (defmethod ig/init-key :nrepl/server - [_ {:keys [port bind ack-port] :as config}] + [_ {:keys [port bind ack-port create-nrepl-port-file?] :as config}] (try (let [server (nrepl/start-server :port port :bind bind :ack-port ack-port)] + (when create-nrepl-port-file? + (nrepl.cmdline/save-port-file server {})) (log/info "nREPL server started on port:" port) (assoc config ::server server)) (catch Exception e (log/error "failed to start the nREPL server on port:" port) (throw e)))) +(defmethod ig/suspend-key! :nrepl/server [_ _]) + (defmethod ig/halt-key! :nrepl/server [_ {::keys [server]}] (nrepl/stop-server server) (log/info "nREPL server stopped")) + +(defmethod ig/resume-key :nrepl/server + [key opts old-opts old-impl] + (ig-utils/resume-handler key opts old-opts old-impl))