【问题标题】:How do I start Hunchentoot?如何启动 Hunchentoot?
【发布时间】:2013-11-02 06:24:45
【问题描述】:

如何在项目中启动 Hunchentoot?我查看了 Edi Weitz 的指南,一切都很顺利,直到安装完成。列出的教程要么被破坏,要么略过实际的服务器使用情况。

我有我的 asdf 文件,使用 quicklisp 安装依赖项,并设置了一个调度表。如何让 Hunchentoot 使用这些东西?

【问题讨论】:

标签: lisp common-lisp hunchentoot


【解决方案1】:

为了更新,我对 Svante 的回答进行了改进:

(defun start-server ()
  (stop-server)
  (start (setf *acceptor*
               (make-instance 'easy-acceptor
                              :port 4242))))

(defun stop-server ()
  (when *acceptor*
    (when started-p *acceptor*
     (stop *acceptor*))))

在启动服务器之前,acceptor 为 nil。在服务器启动后(即使它随后被停止),它不再为零。 started-p 测试检查是否启动了已初始化的 easy-acceptor。如果您尝试停止已停止的接受器,则会收到错误消息。

【讨论】:

    【解决方案2】:

    您在 acceptor 的实例上调用 start

    如果您使用 hunchentoot 附带的基本easy-handler 机制,那就是easy-acceptor

    您将需要一种机制来启动和停止您的服务器。可能看起来像这样:

    (defvar *acceptor* nil)
    
    (defun start-server ()
      (stop-server)
      (start (setf *acceptor*
                   (make-instance 'easy-acceptor
                                  :port 4242))))
    
    (defun stop-server ()
      (when *acceptor*
        (stop *acceptor*)))
    

    【讨论】:

      【解决方案3】:
      (start (defparameter hunchentoot-listener
               (make-instance 'easy-acceptor
                              :port 4242
                              :document-root #p"/path/to/your/html/")))
      

      将在端口 4242 (http://localhost:4242/) 上为您提供一个正在运行的 Web 服务器

      【讨论】:

      • 不要这样使用defparameter。您希望您的顶级表单可重新加载。
      • 我仍然处于学习曲线的上升阶段——你能举一个更容易接受的例子吗?
      • 我在答案中添加了一个示例。
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-04-17
      • 1970-01-01
      • 1970-01-01
      • 2012-07-01
      相关资源
      最近更新 更多