On 03/13/2017 09:38 AM, 'Rickesh Bedia' via Clojure wrote:
> I am trying to start my clojure application on my heroku dyno but I keep
> getting and error in my stuartsierra.component/start.
> 
> Below is my core file containing my main function.
> 
> (defrecord Listener [listener]
>   component/Lifecycle
>   (start [component]
>     (assoc component :listener (yada/listener
>                                  ["/"
>                                   [(view/view-route)
>                                    routes/route-handler
>                                    ["public/" (new-directory-resource
> (io/file "target/cljsbuild/public") {})]
>                                    [true (as-resource nil)]]]
>                                  (or (env :port) (get (read-config
> "resources/config.edn" {:profile :dev}) :webserver))

resources/config.edn is likely incorrect, depending on how you are
running your app. The "resources/" directory is typically on the
classpath, so you refer a file in it as just "config.edn". Referring to
it as "resources/config.edn" is the kind of thing that will work
sometimes at the repl, but depending on how you are packaging and
deploying you app will fail.

The file business with target/ is also something that is likely to fail.

I am not familiar with how heroku deploys clojure, but it looks like
they build an uberjar and run that, so if you want to see how your code
will work there run `lein uberjar` then `java -jar your-uberjar.jar`.

>                                  )))
>   (stop [component]
>     (when-let [close (-> component :listener :close)]
>       (close))
>     (assoc component :listener nil)))
> 
> (defn new-system []
>   (component/system-map
>     :listener (map->Listener {})
>     ))
> 
> (def system nil)
> 
> (defn init []
>   (alter-var-root #'system
>                   (constantly (new-system))))
> 
> (defn start []
>   (alter-var-root #'system component/start))
> 
> (defn stop []
>   (alter-var-root #'system
>                   (fn [s] (when s (component/stop s)))))
> 
> (defn go []
>   (init)
>   (start))
> 
> (defn reset []
>   (stop)
>   (refresh :after 'web.core/go))
> 
> (defn -main
>   [& [port]]
>   (component/start (new-system))
>   (println "System Started")
>   @(promise))
> 
> This is my core file with all my stuartsierra.component code. This all
> works perfectly when I run it locally on my laptop doing lein repl and
> then (go) and also when I just do lein run. So I am confused as to why
> it doesn't work when I push this to the heroku dyno.
> 
> The error I get is
> 
> Exception in thread "main" clojure.lang.ExceptionInfo: Error in
> component :listener in system com.stuartsierra.component.SystemMap
> calling #'com.stuartsierra.component/start {:reason
> :com.stuartsierra.component/component-function-threw-exception,
> :function #'com.stuartsierra.component/start, :system-key :listener,
> :component #web.core.Listener{:listener nil}, :system #<SystemMap>},
> compiling:(/tmp/form-init9049917434081554913.clj:1:73)
> This is telling me that my :listener is nil in the system-map. When I
> check locally (doing lein repl (go)) in (keys system) is (:listener)
> which is good so that means that the listener is starting and is in the
> system.
> 
> When I do (-> system :listener) I get #web.core.Listener{:listener
> {:port 3300, :close #object[yada.aleph$listener$fn__21671 0xa5d4865
> "yada.aleph$listener$fn__21671@a5d4865"], :server
> #object[aleph.netty$start_server$reify__13574 0x3cc9a232
> "aleph.netty$start_server$reify__13574@3cc9a232"]}} which is perfect as
> the port has loaded up (3300) and the server has started.
> 
> This makes it all the more confusing as to why the :listener is nil in
> my heroku app
> 
> Any help would be much appreciated. Thanks
> 
> -- 
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clojure@googlegroups.com
> Note that posts from new members are moderated - please be patient with
> your first post.
> To unsubscribe from this group, send email to
> clojure+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en
> ---
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to clojure+unsubscr...@googlegroups.com
> <mailto:clojure+unsubscr...@googlegroups.com>.
> For more options, visit https://groups.google.com/d/optout.


-- 
And what is good, Phaedrus,
And what is not good—
Need we ask anyone to tell us these things?

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to