Fork me on GitHub
#yada
<
2016-05-13
>
tangrammer07:05:33

Hi guys, did you notice this behaviour when running yada/aleph http server dies immediately => https://github.com/ztellman/aleph/issues/238 ? I'm using now the promise solution but just checking here for a better/different solution too

mccraigmccraig11:05:15

@tangrammer: the promise solution is good - you must have >= 1 non-daemon live Threads or the JVM will exit, and it's better for your app to provide that Thread than for a lib like aleph or yada

malcolmsparks11:05:25

@tangrammer: I haven't noticed it but I'd like to know the circumstances that you're seeing it with because others have complained about it - I haven't given it the proper time it needs

tangrammer11:05:56

@malcolmsparks: just running lein run in a normal yada system with a normal main handler below the handler example

(ns ring.handler
  (:require
   [com.stuartsierra.component :as component]
   [app.config :refer (config)]
   [app.system :refer (new-production-system)]
   [taoensso.timbre :as log])
  (:gen-class))

(def p (promise))

(defn -main []
  (let [system (component/start (new-production-system))]
    (log/info "System starting")
    (log/info "This is your webserver port: " (-> system :webserver :port))
    (log/info ":) > Congrats, your system is ready to use!")
    system
    @p
    ))

malcolmsparks11:05:00

you mean I simple project that uses yada?

malcolmsparks11:05:41

I created a simple project recently https://github.com/juxt/mksmarthack and didn't run into any issues

tangrammer11:05:07

the problem only happens with lein run or java -jar the-uberjar.jar that at last use the main entrypoint

tangrammer11:05:53

i don't see any AOT main class in this mksmarthack project

malcolmsparks11:05:00

ah, that makes sense - because I'm probably using boot repl or something, that's the non-daemon thread that's keeping everything running - I understand now, thanks @tangrammer

stijn12:05:31

@tangrammer: my solution looks like this:

stijn12:05:36

(defn -main [& args]
  (do (component/start
        (system-from-config (env :config-file)
                            "conf/apps.edn"))
      (-> (Thread/currentThread) .join)))

stijn12:05:35

usually a web server will run it's requests on non-daemon threads and the webserver will ensure that your entire application stays running, but like you said not aleph