Am Montag, 15. September 2014 00:20:21 UTC+2 schrieb Wilker: > > I felt that was too much for me, but I'm digging into his source codes to > learn more, and he seems to do a more robust way to shut down the server: > https://github.com/juxt/modular/blob/master/modules/netty/src/modular/netty.clj > This looks interesting. I just had a look into the jetty ring adapter source code and did not find a decidated stop method. Maybe it's time for a feature request?
His version seems to work, but it's for Netty... I'm actually starting to > consider switch to Netty just because of that. > Yea, not being able to restart without having to load up the jvm again and again is really a time stealer. I am curious, why don't you use http-kit? Or why did you decide for jetty / netty? > What I think is weird about that, is that if that was the case, a new > (start) should work after a few seconds, but it doesn't... Jetty seems to > hang on an never closes... For that my guess is that some pending operation > is going on preventing it from shutting down at all... A fix could be a way > to force Jetty to close and wait until it's actually closed. > Maybe it's also an idea to look into the actual jetty source code and find out how they do stop the server, maybe there is a way to call that code from clojure and see what's going on there. Best Regards, Sven > > Thanks for the help. > > --- > Wilker Lúcio > http://about.me/wilkerlucio/bio > Woboinc Consultant > +55 81 82556600 > > On Sun, Sep 14, 2014 at 6:29 PM, Sven Richter <sve...@googlemail.com > <javascript:>> wrote: > >> Hi Wilker, >> >> I have been going the same way and never really found out why this >> happens (I am using http-kit instead of jetty). >> However, one thing that I did not knew was that a refresh will delete >> references of vars. So if you keep your stop function somewhere and call >> refresh before the stop function you will not be able to stop jetty anymore >> and hence, when you try to start it, it is already running. >> >> I implemented my own component library, having the same problems, >> especially when I was using a lot of protocols / records (may have been >> just a coincidence) and finally found about the hara.component library. >> I am using this one now and seem to have less problems. >> >> But, to be honest, I cannot believe that stuarts component library is the >> problem, but my way of using it or coding. >> >> Of course I'd be interested too to hear other opinions. >> >> Best Regards, >> Sven >> >> >> Am Sonntag, 14. September 2014 01:32:44 UTC+2 schrieb Wilker: >>> >>> I forgot to post before, here is the actual error: >>> >>> BindException Address already in use sun.nio.ch.Net.bind0 (Net.java:-2) >>> >>> Also, adding a (Thread/sleep 1000) seems to increase the success rate, >>> but would be nice to be able to really wait on Jetty to shutdown instead of >>> using arbitrary sleep. >>> >>> Thanks. >>> >>> --- >>> Wilker Lúcio >>> http://about.me/wilkerlucio/bio >>> Woboinc Consultant >>> +55 81 82556600 >>> >>> On Sat, Sep 13, 2014 at 8:20 PM, Wilker <wilke...@gmail.com> wrote: >>> >>>> Hi, >>>> >>>> I'm trying to apply the ideas from the component library: >>>> https://github.com/stuartsierra/component >>>> >>>> My problems is being about stop/start the Jetty server, for that >>>> purpose I created this component: >>>> >>>> (defrecord WebServer [app port join? jetty log] >>>> component/Lifecycle >>>> (start [c] >>>> (log "Starting jetty server...") >>>> (let [jetty (jetty/run-jetty (:handler app) {:port port :join? >>>> join?})] >>>> (log "Server started at port" port) >>>> (assoc c :jetty jetty))) >>>> >>>> (stop [c] >>>> (when (:jetty c) >>>> (log "Stopping jetty...") >>>> (.stop (:jetty c)) >>>> (log "Server stopped.")) >>>> >>>> (assoc c :jetty nil))) >>>> >>>> (defn webserver-component >>>> ([port] (webserver-component port true)) >>>> ([port join?] >>>> (map->WebServer {:port port :join? join?}))) >>>> >>>> It works, sometimes, but often I get this when I try to reset: >>>> >>>> Error starting #<ExceptionInfo clojure.lang.ExceptionInfo: Error in >>>> component :server 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 :server, >>>> :component #cadegp.components.web_server.WebServer{:app >>>> #cadegp.components.web_app.CadegpApp{:conn >>>> #cadegp.components.database.Database{:uri >>>> datomic:free://localhost:4334/cadegp, :connection #<Connection {:db-id >>>> cadegp-48d87324-7849-4255-b798-865b02ee9d9d, :index-rev 0, :basis-t >>>> 1176, :next-t 1177, :unsent-updates-queue 0, :pending-txes 0}>}, :handler >>>> #<reload$wrap_reload$fn__1728 >>>> ring.middleware.reload$wrap_reload$fn__1728@6608b223>, >>>> :handler-ext #<user$wrap_dev_handler user$wrap_dev_handler@7e174cba>}, >>>> :port 8000, :join? false, :jetty nil, :log #<core$println >>>> clojure.core$println@7a2c3090>}, :system #<SystemMap>}> >>>> >>>> Seems that it tries to start the server before it have time to shut it >>>> down. >>>> >>>> Any of you had a similar issue or know how to work around that? >>>> >>>> Thanks. >>>> >>>> --- >>>> Wilker Lúcio >>>> http://about.me/wilkerlucio/bio >>>> Woboinc Consultant >>>> +55 81 82556600 >>>> >>> >>> -- >> You received this message because you are subscribed to the Google >> Groups "Clojure" group. >> To post to this group, send email to clo...@googlegroups.com >> <javascript:> >> Note that posts from new members are moderated - please be patient with >> your first post. >> To unsubscribe from this group, send email to >> clojure+u...@googlegroups.com <javascript:> >> 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+u...@googlegroups.com <javascript:>. >> For more options, visit https://groups.google.com/d/optout. >> > > -- 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.