Groups keyboard shortcuts have been updated
Dismiss
See shortcuts

config file (for ring in particular)?

37 views
Skip to first unread message

Dick Davies

unread,
Jan 22, 2013, 5:05:25 AM1/22/13
to clojure...@googlegroups.com
Bit of a noob but have managed to get a well - performing rest service
(plain ring and a bit of c3p0 + jdbc) put together.

Idea is to deploy as an uberjar and then configure it via a config file

e.g.

daemonize java -jar my-rest-thing.jar config.clj

The -main in my app passes the file to a utility function like this:

(defn -main
[configfile]
(let [cfg (utils/load-config configfile)]
(run-jetty handler {:port (cfg :http-port)}))))


Which is fine to configure jetty, but I'm not sure how to 'export' the
'cfg' map
to other functions - jdbc in particular - in the handler.

Would you generally wrap the first arg to run-jetty (with partial or similar),
or set an atom ? I'm guessing the latter, but haven't found any idiomatic code
samples yet.

Thanks.

Dick Davies

unread,
Jan 29, 2013, 9:45:38 AM1/29/13
to Feng Shen, clojure...@googlegroups.com
Thanks, did something very similar in the end.
Seemed a bit odd to use an atom when I'm never going
to change the contents, but works quite nicely.

On 29 January 2013 14:37, Feng Shen <she...@gmail.com> wrote:
> I do something like these for my code:
>
> (defonce configs (atom {}))
>
> (swap! configs merge cfg)
Reply all
Reply to author
Forward
0 new messages