Allow the socket-repl host/port to be customized in project.clj.
This commit is contained in:
parent
484e33397a
commit
8f50fa7572
2 changed files with 14 additions and 4 deletions
|
@ -62,6 +62,9 @@
|
|||
:main org.example.sample
|
||||
;; This will get loaded automatically when you launch a repl.
|
||||
:repl-init-script "src/main/clojure/init.clj"
|
||||
;; Customize the socket the repl task listens on.
|
||||
:repl-port 4001
|
||||
:repl-host "0.0.0.0"
|
||||
;; Emit warnings on all reflection calls.
|
||||
:warn-on-reflection true
|
||||
;; Set this in order to only use the :repositories you list below.
|
||||
|
|
|
@ -77,14 +77,21 @@
|
|||
(catch java.net.ConnectException _ :retry))
|
||||
(recur port)))
|
||||
|
||||
(defn repl-socket-on [{:keys [repl-port repl-host]}]
|
||||
[(Integer. (or repl-port
|
||||
(System/getenv "LEIN_REPL_PORT")
|
||||
(dec (+ 1024 (rand-int 64512)))))
|
||||
(or repl-host
|
||||
(System/getenv "LEIN_REPL_HOST")
|
||||
"localhost")])
|
||||
|
||||
(defn repl
|
||||
"Start a repl session. A socket-repl will also be launched in the
|
||||
background; use the LEIN_REPL_PORT environment variable to set the port."
|
||||
background on a socket based on the :repl-port key in project.clj or
|
||||
chosen randomly."
|
||||
([] (repl {}))
|
||||
([project]
|
||||
(let [host (or (System/getenv "LEIN_REPL_HOST") "localhost")
|
||||
port (Integer. (or (System/getenv "LEIN_REPL_PORT")
|
||||
(dec (+ 1024 (rand-int 64512)))))
|
||||
(let [[host port] (repl-socket-on project)
|
||||
server-form (repl-server project host port)]
|
||||
(future (try (if (empty? project)
|
||||
(clojure.main/with-bindings
|
||||
|
|
Loading…
Reference in a new issue