【问题标题】:SBCL: Deploying Hunchentoot application as executableSBCL:将 Hunchentoot 应用程序部署为可执行文件
【发布时间】:2015-05-24 10:25:59
【问题描述】:

我开始使用 SBCL Common Lisp 并想使用 Hunchentoot 开发一个小型 Web 应用程序。为了便于部署,我计划使用 sb-ext:save-lisp-and-die 将所有内容保存在二进制文件中,因为我可以忍受较大的输出大小。

对于可执行文件,您需要提供顶级函数。问题是当顶层函数返回时程序退出。我尝试从可执行文件中启动 Hunchentoot,但程序在两秒钟后结束。

如何才能等到 Hunchentoot 被关闭(从请求内部)再停止程序?我可以做一些事情,比如加入 Hunchentoot 接受者线程吗?或者我什至可以将 REPL 包含到可执行文件中以便能够进行实时调试?

【问题讨论】:

  • 你有没有想过如何部署你的应用程序?我现在处于同样的位置。我写了一个快速应用程序并想部署它。你用了什么工具?
  • @MadPhysicist 我正在 lisp-journey/web-dev#deployment 上做笔记。只是不能肯定地说,因为由于 sbcl 错误,我还不能运行我的应用程序。
  • @Ehvince 太棒了!我会密切关注它。顺便说一句,我很想得到一份 Lisp 资源列表,这些资源对你的 Lisp 之旅很有用。对书籍、在线文章等的建议。
  • 我发现真正有用的资源基本上都在 Good Resources 选项卡中,+ E. Weitz 的 CL 食谱(强烈建议对实际事物有一个大的概述。虽然缺乏现代工具和库)+ 阅读来源。

标签: common-lisp executable sbcl hunchentoot


【解决方案1】:
(ql:quickload :hunchentoot)
(use-package :hunchentoot)

(defun main ()
  (hunchentoot:start-server :port 8082)
  (sb-thread:join-thread (find-if
                          (lambda (th)
                            (string= (sb-thread:thread-name th) "hunchentoot-listener-1"))
                          (sb-thread:list-all-threads))))

如果您保持终端打开(可能通过 GNU Screen),则无需显式代码即可让您访问 REPL。发送 Ctrl+C 到终端以进入调试器。

【讨论】:

  • 看来我正在使用更新版本的 Hunchentoot。我不得不使用 (hunchentoot:start (make-instance 'hunchentoot:easy-acceptor :port 8080) 并且线程被称为“hunchentoot-listener-*:8080”。就像一个魅力。
  • (find-if (lambda (th) (search "hunchentoot-listener" (sb-thread:thread-name th))) (sb-thread:list-all-threads))find-if 部分怎么样
猜你喜欢
  • 1970-01-01
  • 2012-12-28
  • 1970-01-01
  • 2015-09-26
  • 2020-10-10
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多