Clojure REPL 连接远程会话

学习 Clojure 一般是用 lein repl 启动控制台, 每次启动 lein repl 都会发现它打开了一个端口, 例如

➜ ~ lein repl
nREPL server started on port 57212 on host 127.0.0.1 - nrepl://127.0.0.1:57212
REPL-y 0.3.7, nREPL 0.2.12
Clojure 1.8.0
...........

一直不清楚上面显示的 nrepl://127.0.0.1:57212 该作何用, 而且端口号是随机的, 这其中定有文章.

幸好有 Google 帮忙, 查一查, 然后才意识到何不运行  lein help repl 来看看 repl 中到底有何玄机, 原来是:

<none> -> :start     lein repl 默认的行为, 见下. 未指定 :host 或 :port , :host 默认为 127.0.0.1,  :port 为随机
:start [:host host] [:port port] 原来  lein repl 设计为为 CS 结构. :start 会启动一个 nREPL  server, 并且立即启动一个 client 连接上它. :host 默认为 127.0.0.1, :port 默认为随机的
:headless [:host host] [:port port]   只启动 nREPL server, 等待别人来连接它, 相同的默认 :host, :port 规则.  也就是它不会进到 Clojure 控制台
:connect [dest]   连接一个 nREPL server. 目标服务器的指定有三种方式: HTTPS(S) URL, host:port, 或 port 阅读全文 >>