On Tue, Feb 12, 2013 at 9:10 PM, Ari <ari.brandeis.k...@gmail.com> wrote:

> How does one bootstrap web apps comprised of ring + compojure (and/or
> aleph) + hbase/mongodb? Is there a best practice or recommended way? For
> example, in Rails based apps a series of predetermined "initialization"
> files are executed to fulfill various tasks, i.e. connect to dbs, message
> queues, active background jobs, etc. Thanks.
>

I've solved it by creating a bootstrap-function in my handler.clj, that
inits/bootstraps
the required components/namespaces in turn, like this:

(defn bootstrap! []
  (scheduler/bootstrap!)
  (mongo/bootstrap!))

...and passing it to ring's init-param in my project.clj, like this:

:ring {:init myapp.handler/bootstrap!
        ...}

I came up with this in the heat of the moment when I realized that I needed
a one-time bootstrapping step at startup, so by no means would I tout this
as "the one proper way" to do it.

My application is not big enough that this is really a concern for me, but
I'm
not that enticed by adding direct dependencies to everything that needs
bootstrapping in my handler.clj.
As a somewhat nicer solution, I considered separating out the
handler/bootstrap!-
function into a separate bootstrap.clj that would pull in the required
namespaces
 and have handler.clj depend only on that.

I'd love to hear how other people solved this, and thoughts in general.

-- 
-- 
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/groups/opt_out.


Reply via email to