如何在clojure中停止jetty服务器

如何在clojure中停止jetty服务器

本文介绍了如何在clojure中停止jetty服务器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用ring和clojure编写一个Web应用程序。我使用jetty适配器的开发服务器和emacs / SLIME的IDE。虽然wrap-reload有帮助,run-jetty阻止我的slime会话,我想要能够启动/停止它,而不必在单独的终端会话中运行它。理想情况下,我想定义一个服务器代理和函数start-server和stop-server,启动/停止代理中的服务器。这是可能吗?

I am writing a web application using ring and clojure. I am using the jetty adapter for the development server and emacs/SLIME for IDE. While wrap-reload does help, run-jetty blocks my slime session and I would like to be able to start/stop it at will without having to run it in a separate terminal session. Ideally, I would like to define a server agent and functions start-server and stop-server that would start/stop the server inside the agent. Is this possible?

推荐答案

我通常在我的Ring应用程序中有一行如下:

I usually have a line in my Ring app that looks like the following:

(defonce server (run-jetty #'my-app {:port 8080 :join? false}))

这可以防止锁定REPL。它还允许我重新编译这个文件,而不必担心我的服务器会被重新定义。它还允许您在REPL中进行交互:

This prevents locking up the REPL. It also allows me to recompile this file without worrying that my server will get redefined. It also lets you interact at the REPL like so:

user=> (.stop server)

user=> (.start server)

这篇关于如何在clojure中停止jetty服务器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-01 17:26