简体   繁体   English

在Emacs Cider REPL中使用重装包装环

[英]Ring with reload-wrap in Emacs Cider REPL

When starting a Ring server from within an Emacs Cider REPL via reload-wrap, the REPL blocks. 通过重载包装从Emacs Cider REPL内部启动Ring服务器时,REPL会阻塞。 What can I do in order to have this code-reloading feature during development and being able to keep on working with the Cider REPL at the same time. 为了在开发过程中具有此代码重新加载功能并能够同时与Cider REPL一起工作,我该怎么办。

Aditionally, after cancelling the running server "process" from within the REPL by hitting Cc CC, I cannot restart it on the same port, I'm getting the "address already in use" error. 另外,通过按Cc CC从REPL中取消正在运行的服务器“进程”后,我无法在同一端口上重新启动它,出现“地址已在使用”错误。

I know this is possible with Stuart Sierra's component system. 我知道使用Stuart Sierra的组件系统可以做到这一点。 Is this the only way to go or is there maybe a simpler solution? 这是唯一的方法吗,或者也许有一个更简单的解决方案?

When you start your ring server (I guess using jetty) you are not telling it to not join the current thread to the running server. 当您启动环形服务器(我猜想使用码头)时,您并不是在告诉它不要将当前线程加入正在运行的服务器中。 You need to add join? 您需要添加join? option set to false : 选项设置为false

(run-jetty my-handler {:join? false})

You should also bind the return value of this expression which is the server instance, so you can stop it later: 您还应该绑定此表达式的返回值(即服务器实例),以便稍后可以停止它:

(def my-server (run-jetty my-handler {:join? false}))
;; some time later
(.stop my-server)

Stopping the server will close the server socket and make it available for future server instances. 停止服务器将关闭服务器套接字,并使其可用于将来的服务器实例。

Simplier solution, to store web-server same wasy as component does somewhere in dev/user.clj. Simplier解决方案,用于在dev / user.clj中的某处存储与组件相同的Web服务器浪费。 And configure cider-refresh-fn variable to start and stop web-server. 并配置cider-refresh-fn变量以启动和停止Web服务器。 Actually, idea is the same as in component approach, however you don't have to use it, 实际上,想法与组件方法相同,但是您不必使用它,

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM