【问题标题】:lein REPL server launch timed outlein REPL 服务器启动超时
【发布时间】:2014-05-09 08:07:43
【问题描述】:

在一个基于 liberator 的 clojure 项目中,我们使用 datomic 作为 DB。在将我们的本地开发数据库迁移到 S3 托管的数据库并在我们的 project.clj 上添加所需的依赖项后,我们无法启动 REPL,但 Liberator 堆栈通过lein run 运行良好

我的猜测是数据库连接搞砸了,所以,问题是,我怎样才能以某种方式“调试”或找出这个 lein repl 超时的原因是什么?

我的项目.clj

(defproject myproject "0.1.0-SNAPSHOT"
  :main myproject.core
  :jvm-opts ["-Xmx1G"]
  :datomic {:schemas ["resources" ["myproject-schema.edn" ]]}
  :plugins [[lein-ring "0.8.10"]]
  ; cp bin/transactor config/samples/free-transactor-template.properties resources/transactor.properties
  :profiles {:dev
             {:datomic {
                        ; :config resources/transactor.properties
                        ; :db-uri "datomic:free://127.0.0.1:4334/myproject"}
                        :db-uri "datomic:ddb://us-east-1/datomica/myproject"}

 :dependencies [[ring-mock "0.1.5"]
                             [midje "1.5.1"]
                             ]
              }
             }
  :dependencies [[org.clojure/clojure "1.5.1"]
                 [com.datomic/datomic-pro "0.9.4556"]
                 ; [com.datomic/datomic-free "0.9.4470"]
                 [com.cemerick/friend "0.2.0"]
                 [liberator "0.10.0"]
                 [compojure "1.1.5"]
                 [http-kit "2.1.13"]
                 [cheshire "5.1.1"]
                 [ring/ring-jetty-adapter "1.1.0"]
                 [ring/ring-devel "1.2.0"]
                 [org.clojure/clojure-contrib "1.2.0"]
                 [url62 "1.0.0-SNAPSHOT"]
                 [clj-http "0.7.8"]
                 [org.clojars.nathell/clojure-contrib "1.2.0"]
                 [com.taoensso/timbre "3.0.0-RC4"]
                 [clj-aws-s3 "0.3.8"]
                 [image-resizer "0.1.5"]
                 [pandect "0.3.1"]
                 [base64-clj "0.1.1"]
                 ]
    :ring {
           :handler myproject.core
           }
)

我的profiles.clj

cat ~/.lein/profiles.clj                                                           
{:user {:dependencies [[slamhound "1.5.0"]]
        :aliases {"slamhound"["run" "-m" "slam.hound"]}
        :plugins [[lein-datomic "0.2.0"]
                  [lein-midje "3.0.0"]
                                  [lein-html5-docs "2.0.0"]
                                  [lein-pprint "1.1.2-SNAPSHOT"]]
                ; :datomic {:install-location "/opt/datomic-free"}
                :datomic {:install-location "/opt/datomic-pro/"}
                }
}%      

我的.zshrc

export CLASSPATH=$CLASSPATH:/home/user:/opt/datomic-pro:.

我的环境

Leiningen 2.3.3 on Java 1.7.0_25 OpenJDK 64-Bit Server VM
Linux 3.8.0-35-generic #50-Ubuntu SMP Tue Dec 3 01:24:59 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux

【问题讨论】:

    标签: clojure leiningen read-eval-print-loop datomic


    【解决方案1】:

    有时可能需要一段时间才能将所有鸭子整理好。在您的 project.clj 文件中指定 :repl-options 并具有较长的超时时间,如下所示:

    :repl-options {
                 ;; If nREPL takes too long to load it may timeout,
                 ;; increase this to wait longer before timing out.
                 ;; Defaults to 30000 (30 seconds)
                 :timeout 120000
                 }
    

    希望这样可以解决问题。

    【讨论】:

    • 谢谢,这个答案也帮助我配置了 nREPL,因为我不知道这个选项。
    【解决方案2】:

    原因是对多个文件之间的Datomic连接进行了多次重新定义和评估

    (def conn (d/connect DATOMIC_URI))
    

    这个话题的解决方案已经在How to deal with a variable in a library that needs to be set outside of it?讨论过

    【讨论】:

    • Stuart Sierra的Component pattern/lib也很好的解决了这个问题。
    【解决方案3】:

    在 project.clj 中的字段 :repl-options 中设置超时值,默认为 30000(30s)。 例如:

    :repl-options{:timeout 120000}
    

    【讨论】:

      猜你喜欢
      • 2012-11-20
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2010-09-18
      • 1970-01-01
      • 2022-11-30
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多