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 [email protected]
Note that posts from new members are moderated - please be patient with your
first post.
To unsubscribe from this group, send email to
[email protected]
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 [email protected].
For more options, visit https://groups.google.com/d/optout.