This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2021-03-23
Channels
- # announcements (2)
- # architecture (83)
- # asami (2)
- # babashka (49)
- # bangalore-clj (2)
- # beginners (235)
- # braveandtrue (1)
- # calva (17)
- # clojure (109)
- # clojure-australia (5)
- # clojure-czech (5)
- # clojure-dev (24)
- # clojure-europe (17)
- # clojure-germany (2)
- # clojure-nl (3)
- # clojure-serbia (13)
- # clojure-spain (1)
- # clojure-spec (1)
- # clojure-uk (20)
- # clojurescript (3)
- # community-development (34)
- # conjure (10)
- # cursive (21)
- # data-science (1)
- # datahike (1)
- # datalog (1)
- # datomic (12)
- # etaoin (3)
- # events (2)
- # fulcro (13)
- # graphql (8)
- # heroku (2)
- # lsp (58)
- # malli (32)
- # membrane (24)
- # off-topic (63)
- # parinfer (2)
- # pathom (14)
- # portal (14)
- # re-frame (16)
- # reagent (50)
- # releases (1)
- # rum (1)
- # shadow-cljs (10)
- # sql (6)
- # startup-in-a-month (1)
- # timbre (2)
- # tools-deps (61)
- # xtdb (4)
Hi fellow clojurians Im deploying clojure deps.edn app to heroku. and it deployed successful. But heroku dyno restart (happens once every day automatically ) fails with
Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 150 seconds of launch
Here my Procfile command
web: java -cp ps.jar clojure.main -m reviews.system
and here is my main system file,
Locally it takes around 30 seconds to start up server
(ns reviews.system
(:require [integrant.core :as ig]
[ring.adapter.jetty :as jetty]
[reviews.server :as server]
[migratus.core :as migratus]
[migrations :as migrations]
[reviews.db :as db]))
(def system-config
{:shop/jetty {:handler (ig/ref :shop/handler)
:port (Integer. (or (System/getenv "PORT") "3000"))}
:shop/handler {:db (ig/ref :shop/postgres)}
:shop/migrations {:db (ig/ref :shop/postgres)}
:shop/postgres nil})
(defmethod ig/init-key :shop/jetty [_ {:keys [handler port] }]
(println "server running on port 3000")
(jetty/run-jetty handler {:port port :join? false}))
(defmethod ig/init-key :shop/migrations [_ {:keys [db] }]
(let [config {:db {:datasource {:datasource db}}}]
(migratus/migrate migrations/config)))
(defmethod ig/init-key :shop/handler [_ {:keys [db] }]
(server/create-app db))
(defmethod ig/init-key :shop/postgres [_ _]
db/spec)
(defmethod ig/halt-key! :shop/jetty [_ jetty]
(.stop jetty))
(defn -main []
(println "Running main!")
(println "PORT: " (Integer. (or (System/getenv "PORT") "3000")))
(ig/init system-config))
(comment
(def system (ig/init system-config))
(ig/halt! system))
@umardaraz4747 Starting jetty by itself should be pretty instantaneous, so assume it must be due to the database or what you are doing to the database. If you are on a free plan for Heroku Postgres, check you are not exceeding the 10,000 row limit. Is there anything else in the heroku logs?
heroku logs --app your-heroku-app-name --tail
I would look at the logs and emulate a restart by using the following commands a suitable time apart
heroku ps:stop your-heroku-app-name
heroku ps:stop your-heroku-app-name
All the logs have timestamps, so you should be able to see how long its taking...
I would look for issues connecting to the db or perhaps migrations. Perhaps add some printlin or logging expressions to the migrations to see how quickly that is doing something.
I am unsure what the Integrant :shop/postgres is doing, perhaps its just defining the JDBC_DATABASE_URL
environment variable to connection to the database. I assume its not trying to start/restart the Heroku Postgres database.
I would also consider separating out Migrations into its own project and run that as an independant Heroku application, that way your web application server is not dependant on a potentially lengthy database migration step.
If you are happy to share a repository of the code, I can try deploying it myself on Heroku and see if I can spot any issues.