-
Notifications
You must be signed in to change notification settings - Fork 524
Interactive Development
miikka edited this page Feb 5, 2011
·
24 revisions
If you want to reload your source files without needing to restart your adapter, you need to:
- Run your adapter in a background thread so it doesn't block your REPL.
- Pass your handler function to the adapter as a var, so it will be updated when you reload the namespace.
For example:
(future (run-jetty (var my-handler) {:port 8080}))
You can also use Lein-Ring. It's a Leiningen plugin for automating common Ring tasks. It provides a command to start a development web server that automatically reloads modified source files. Add it as a dependency to your project.clj
:
:dev-dependencies [[lein-ring "0.3.0"]]
You also need to add a new ring
key, which specifies your Ring handler function, like this:
:ring {:handler hello-world.core/handler}))
Here's an updated project.clj
for the Getting started tutorial:
(defproject hello-world "1.0.0-SNAPSHOT"
:description "FIXME: write"
:dependencies [[org.clojure/clojure "1.2.0"]
[org.clojure/clojure-contrib "1.2.0"]
[ring/ring-core "0.3.4"]
[ring/ring-jetty-adapter "0.3.4"]]
:dev-dependencies [[lein-ring "0.3.0"]]
:ring {:handler hello-world.core/handler}))
Now run the command lein ring server
to start the web server. For more information, see Lein-Ring's README.