diff options
author | Matthias Andreas Benkard <code@mail.matthias.benkard.de> | 2012-08-19 14:14:53 +0200 |
---|---|---|
committer | Matthias Andreas Benkard <code@mail.matthias.benkard.de> | 2012-08-19 14:14:53 +0200 |
commit | 9e77c6d0ae99198981ee3ea4906d7698ec523311 (patch) | |
tree | ebbd6c8c39bacdc997fba72ecbdd3743123d821a /src | |
parent | 14fb45c2d47095381da6df8d5b5e151319d404ef (diff) |
Make the Benki compatible with Immutant.
Diffstat (limited to 'src')
-rw-r--r-- | src/mulk/benki/main.clj | 39 | ||||
-rw-r--r-- | src/mulk/benki/util.clj | 19 |
2 files changed, 37 insertions, 21 deletions
diff --git a/src/mulk/benki/main.clj b/src/mulk/benki/main.clj index 35f6e03..9849a31 100644 --- a/src/mulk/benki/main.clj +++ b/src/mulk/benki/main.clj @@ -143,17 +143,36 @@ (org.bouncycastle.jce.provider.BouncyCastleProvider.)) (Class/forName "net.java.dev.sommer.foafssl.sesame.verifier.SesameFoafSslVerifier")) +(defn run-immutant-swank! + "Call `immutant.repl/start-swank` 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 :swank)] + (when (and (get swank-config :enabled true) + (try + (require 'immutant.repl) + true + (catch Exception e + false))) + ((ns-resolve 'immutant.repl 'start-swank) + (:bind swank-config) (:port swank-config)) + true))) + +(defn init! [] + (init-config!) + (init-middleware!) + (noir.server/load-views-ns 'mulk.benki) + (init-security!) + (future (run-immutant-swank!)) + (future (require 'mulk.benki.xmpp) + ((ns-resolve 'mulk.benki.xmpp 'init-xmpp!))) + (future (require 'mulk.benki.lazychat) + ((ns-resolve 'mulk.benki.lazychat 'init-lazychat!))) + (future (reset! server (run-server)))) + (defn -main [& args] - (do - (init-config!) - (init-middleware!) - (noir.server/load-views-ns 'mulk.benki) - (init-security!) - (future (require 'mulk.benki.xmpp) - ((ns-resolve 'mulk.benki.xmpp 'init-xmpp!))) - (future (require 'mulk.benki.lazychat) - ((ns-resolve 'mulk.benki.lazychat 'init-lazychat!))) - (future (reset! server (run-server)))) + (init!) (loop [] (Thread/sleep 1000000) (recur))) diff --git a/src/mulk/benki/util.clj b/src/mulk/benki/util.clj index 366e9c0..db27432 100644 --- a/src/mulk/benki/util.clj +++ b/src/mulk/benki/util.clj @@ -8,7 +8,8 @@ [noir.request :as request] [noir.response :as response] [clojure.java.jdbc :as sql] - [clojure.pprint]) + [clojure.pprint] + [clojure.tools.logging :as logging]) (:import [java.text DateFormat] [java.security SecureRandom] [java.math BigInteger] @@ -145,15 +146,11 @@ ;;;; * Debugging -(defonce logger - (org.apache.log4j.Logger/getLogger "eu.mulk.benki")) +(defmacro info [& args] + `(logging/info ~@args)) -(defn info [s] - (.info logger s)) - -(defn log [s] - (.info logger s)) - -(defn debug [s] - (.debug logger s)) +(defmacro debug [& args] + `(logging/debug ~@args)) +(defmacro log [& args] + `(logging/info ~@args)) |