我有一个使用ring和compojure构建的小型Clojure webapp。虽然webapp运行在我的笔记本电脑上本地查找,但当我推送到Heroku时,应用程序崩溃了。日志中的特定错误是
Starting process with command `java $JVM_OPTS lein ring server-headless 3000`
app[web.1]: Error: Could not find or load main class lein
app[web.1]: Picked up JAVA_TOOL_OPTIONS: -Xmx384m -Djava.rmi.server.useCodebaseOnly=true
heroku[web.1]: State changed from starting to crashed
我的project.clj
看起来像
(defproject hn-clj "0.1.1"
:description "foo"
:url "http://foo"
:min-lein-version "2.0.0"
:dependencies [[org.clojure/clojure "1.6.0"]
[compojure "1.3.1"]
[ring/ring-defaults "0.1.2"]
[clj-http-lite "0.2.0"]
[cheshire "5.4.0"]
[hiccup "1.0.5"]]
:plugins [[lein-ring "0.8.13"]]
:ring {:handler hn-clj.core.handler/app}
:profiles
{:dev {:dependencies [[javax.servlet/servlet-api "2.5"]
[ring-mock "0.1.5"]]}}
)
该应用程序的入口点位于src/core/handler.clj
(ns hn-clj.core.handler
(:require [compojure.core :refer :all]
[compojure.route :as route]
[compojure.handler :as handler]
[ring.middleware.defaults :refer [wrap-defaults site-defaults]]
[hn-clj.core.controllers.story :as story]
[hn-clj.core.controllers.users :as users]
))
(defroutes app-routes
(GET "/" [limit] (story/index limit))
(GET "/stories/:id" [id] (story/show-story id))
(GET "/users/:username" [username] (users/show username)))
(def app
(wrap-defaults app-routes site-defaults))
本地应用程序运行查找lein ring server-headless 3000
并在Procfile
我已放置
web: java $JVM_OPTS lein ring server-headless 3000
虽然我没有创建main-
函数,但这并不禁止应用程序在本地运行,我不明白为什么应用程序在部署到Heroku时不会运行。我应该如何重构handler.clj
或Procfile
?