cryogen-project / cryogen

A simple static site generator written in Clojure
http://cryogenweb.org/
Eclipse Public License 1.0
1.1k stars 96 forks source link

Heroku deployment #180

Closed bitcoinminersuk closed 4 years ago

bitcoinminersuk commented 5 years ago

I am trying to deploy a Cryogen site to heroku and I am getting the following errors in the logs

loading module: Markdown parser 2019-05-07T01:12:11.270230+00:00 heroku[web.1]: State changed from starting to crashed 2019-05-07T01:12:11.168013+00:00 app[web.1]: compiling assets... 2019-05-07T01:12:11.168505+00:00 app[web.1]: Error: Not a file: jar:file:/app/target/cryogen-standalone.jar!/templates/config.edn 2019-05-07T01:12:11.168863+00:00 app[web.1]: "Elapsed time: 0.990418 msecs" 2019-05-07T01:12:11.250187+00:00 heroku[web.1]: Process exited with status 0 2019-05-07T01:12:27.364291+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=jimmymothy.herokuapp.com request_id=09602c38-9626-4270-9368-b14266d5973c fwd="82.102.19.198" dyno= connect= service= status=503 bytes= protocol=https

The project.clj is as follows:

`(defproject cryogen "0.1.0" :description "Simple static site generator" :url "https://github.com/lacarmen/cryogen" :license {:name "Eclipse Public License" :url "http://www.eclipse.org/legal/epl-v10.html"} :dependencies [[org.clojure/clojure "1.10.0"] [ring/ring-devel "1.7.1"] [compojure "1.6.1"] [ring-server "0.5.0"] [cryogen-markdown "0.1.9"] [cryogen-core "0.1.67"]] :plugins [[lein-ring "0.12.5"]]

:min-lein-version "2.0.0"

:uberjar-name "cryogen-standalone.jar"

:main cryogen.core :ring {:init cryogen.server/init :handler cryogen.server/handler})`

and I have the procfile as I was advised (I have tried a few variations but still get the same error):

web: java $JVM_OPTS -cp target/cryogen-standalone.jar clojure.main -m cryogen.core

I would be grateful for any help and once I have it working I should be able to help put a small guide for others that wish to use heroku.

Cheers

Jim

lacarmen commented 5 years ago

Are you trying to run the actual cryogen project on Heroku or just deploy the static content?

bitcoinminersuk commented 5 years ago

Apologies for the delayed reply, I am trying to run it on heroku

lacarmen commented 5 years ago

If you are running the project from a jar then it won't be able to read the config file. This error comes from this function when it's called by read-config.

io/resource returns a URL, and when running with lein the URL happens to be a file:// URL so io/file can accept it. However, once the resource is in a jar that is no longer the case.

You might be able to get it to work by removing the call to io/file from that function but find-assets also uses get-resource and I don't know if that will cause issues. If you're looking to host your site it's much better to generate the assets and host the statically rather than keeping the project running.