summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthias Andreas Benkard <code@mail.matthias.benkard.de>2012-08-22 08:30:40 +0200
committerMatthias Andreas Benkard <code@mail.matthias.benkard.de>2012-08-22 08:30:40 +0200
commite1a1f43acf513b79e1a2df61680c8ae635c61fbc (patch)
treeb645cdfc81942ba32f5165d123c4cf4d59f817b9
parent0fbfe4359681645c3faeea4acd536f7a2ad49c05 (diff)
Add nREPL support when running on Immutant.
-rw-r--r--resources/config.sexp.sample3
-rw-r--r--src/mulk/benki/main.clj17
2 files changed, 20 insertions, 0 deletions
diff --git a/resources/config.sexp.sample b/resources/config.sexp.sample
index a1e3a36..3f4e06f 100644
--- a/resources/config.sexp.sample
+++ b/resources/config.sexp.sample
@@ -15,6 +15,9 @@
:swank {:enabled true ;will be assumed true if absent
:port 4005
:bind "127.0.0.1"}
+ :nrepl {:enabled true ;will be assumed true if absent
+ :port 4111
+ :bind "127.0.0.1"}
:xmpp {:enabled true ;will be assumed true if absent
:user "benki"
:service-name "example.com"
diff --git a/src/mulk/benki/main.clj b/src/mulk/benki/main.clj
index 47bca8d..0392902 100644
--- a/src/mulk/benki/main.clj
+++ b/src/mulk/benki/main.clj
@@ -159,6 +159,22 @@
(:bind swank-config) (:port swank-config))
true)))
+(defn run-immutant-nrepl!
+ "Call `immutant.repl/start-nrepl` with the Swank configuration
+ specified in `benki-config`. If loading the immutant.repl namespace
+ fails, ignore the error and return `nil` without doing anything. In
+ case of success, return true." []
+ (when-let [swank-config (get @benki-config :nrepl)]
+ (when (and (get swank-config :enabled true)
+ (try
+ (require 'immutant.repl)
+ true
+ (catch Exception e
+ false)))
+ ((ns-resolve 'immutant.repl 'start-nrepl)
+ (:bind swank-config) (:port swank-config))
+ true)))
+
(defn init! []
(init-config!)
(init-middleware!)
@@ -167,6 +183,7 @@
(doseq [ns '(mulk.benki.book_marx mulk.benki.lazychat)]
(require ns))
(future (run-immutant-swank!))
+ (future (run-immutant-nrepl!))
(future (require 'mulk.benki.xmpp)
((ns-resolve 'mulk.benki.xmpp 'init-xmpp!)))
(future (require 'mulk.benki.lazychat)