I have a picture gallery application I made from the "Web Development with Clojure" book and I am at the point of deploying it to Heroku. I have tried making it work as both a standalone uberjar and with trampoline. I tried to use environ in the beginning, but kept getting database value errors on "db-spec" so I stopped using it to make it run fine locally. I tried to set my own environment variables, and also to use a main.clj file. I edited my profile settings info and can get it to deploy but not run properly on heroku. Sometimes I get a blank screen and can navigate to a few of my pages and then sometimes I get an h10 app crashed error on a GET that is looking for a favicon, which is hard to troubleshoot.
Could someone with experience tell me specifically what I need to write and in what files to make it work in production on Heroku? Bonus points if you can also demystify the environment variables and db connections settings with Postgres in Heroku for me.
I have scoured the heroku, environ and leiningen docs. I have also searched for the same problem on stack and of course triple worked through all the examples in my book, which are mirrored by the luminus docs, cause the same guy wrote them. The link to my app is below. Below is a link to one version of the project I put up on github.
https://github.com/gamma235/picture-gallery
This is how I have defined my database:
(def db
{:subprotocol "postgresql"
:subname "//localhost/gallery"
:user "admin"
:password "admin"})
This is my main.clj file:
(ns picture-gallery.main
(:use picture-gallery.handler
[org.httpkit.server :only [run-server]]
[ring.middleware file-info file])
(:gen-class))
(defn -main [& [port]]
(let [port (if port (Integer/parseInt port) 3000)]
(run-server app {:port port})
(println (str "You can view the site at http://localhost:" port)))))
I am using [org.clojure/java.jdbc "0.2.3"]
for my database needs. It is the old version but I am following along with the book.
Here are significant parts of my project.clj file:
...
:main picture-gallery.main
:min-lein-version "2.0.0"
:plugins [[lein-ring "0.8.7"]]
:ring {:handler picture-gallery.handler/app
:init picture-gallery.handler/init
:destroy picture-gallery.handler/destroy}
:profiles
{:uberjar {:main picture-gallery.main, :aot :all}}
)
I followed the heroku shouter app tutorial here and deployed it with little fuss. I am unable to figure out how alter the code in my picture-gallery app, based on this project, however. Things like $JVM_OPTS
in the Procfile are mysterious to me. Any explanations or referrals are welcome. Please browse the source-code for the heroku app and succeed where I have failed.