ClojureBridge/curriculum

Unable to deploy to Heroku

Closed this issue ยท 8 comments

Locally, everything is running just fine, but I keep getting an application error when I run heroku open as instructed in "Putting Your Application Online"

Things I've tried already:

  • In project.clj, updated Lein with :min-lein-version "2.0.0" as instructed on heroku dev center
  • In web.clj requirements, added [hiccup.form :as form] and [ring.adapter.jetty :as ring]
  • In project.clj, added :main ^:skip-aot global-growth.web
  • In web.clj, added (defn -main [] (ring/run-jetty #'main-routes {:port 8080 :join? false})

There was also talk of this being an issue with Procfile (there isn't one?), but I'm not sure what's going on. Any ideas? Let me know if you'd like me to copy in any of my heroku logs.

Related: Is there recommended documentation on clojure app deployment via github.io?

Thanks for all your help in advance! ๐Ÿ˜„

Has anyone solved this?

This has not been solved, and I don't know that anyone has reproduced it yet, either.

Is there a Procfile that needs to be added to deploy to heroku and if so how does it look like. I'm new to clojure but with my experiences with nodejs, I always added a procfile to my node apps.

Hi @kwistens , @bridgethillyer, and @selasiehanson,

I wrote the docs for Heroku deployment, and I'm getting an application error too.

A Procfile isn't necessary in most languages, since Heroku can figure out what language you're using and create a default web process type to start the application server.

But a Procfile does provide more control over deployment, and given the error here without one, I'm trying various iterations of the Procfile as recommended here. Here are a couple:

  • web: lein with-profile production trampoline run -m global_growth.web
  • adding :uberjar-name "global-growth-standalone.jar" to project.clj
    and creating a Procfile with the following:
    web: java $JVM_OPTS -cp target/global-growth-standalone.jar clojure.main -m global_growth.web

For the latter, I get this log error: Exception in thread "main" java.lang.Exception: Cannot find anything to run for: global_growth.web This makes sense since there isn't a function called main in web.clj. I also tried deploying with clojure.main-page and clojure.main-routes instead of clojure.main. No dice.

I haven't had success yet. Perhaps someone with more robust knowledge of the JVM can help?

I had the same issue and here's what worked for me:

  1. Adding :min-lein-version "2.0.0" to project.clj
  2. Creating a Procfile with web: lein ring server

This was enough to make the app run on Heroku and I've made no other changes to the template except uncommenting the code in core.clj and web.clj. This Procfile is probably not the best way to do this, since ring docs mention that lein ring server starts a development server. I've tried replacing it with web: lein with-profile production trampoline ring server-headless and it still works, but I'm not sure if it's in any way better.

Thanks, @allait!

Your comments, along with this, were very helpful.

Here's what worked for me. Almost identical to yours, but it includes a slight modification to the Procfile:

  1. Add :min-lein-version "2.0.0" to project.clj
  2. Create a Procfile with web: lein ring server-headless $PORT

I will update the docs accordingly.

Looks like this issue was resolved a long while ago, but the issue remains open.

Closing it now!

@kpfell ๐Ÿ‘ Thanks! Hope all is well.