Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a way to do a hot reload in compojure?

I'm new to clojure and compojure and I was wondering if there's a way to do a hot reload of code changes as you can with Ruby's Sinatra (with the shotgun gem) or Java's Play!

I'm following along with this Heroku tutorial so if there's a way to do it with the foreman gem that would work too.

thanks!

like image 783
kreek Avatar asked Dec 15 '11 00:12

kreek


2 Answers

Take a look at this SOq:

  • Compojure development without web server restarts

and this tutorial:

  • http://mmcgrana.github.com/2010/03/clojure-web-development-ring.html

The suggestion is to use ring's reload middleware.

like image 93
icyrock.com Avatar answered Oct 06 '22 01:10

icyrock.com


Recent versions of Compojure make it even easier by incorporating all of the middleware into a single function call:

https://github.com/weavejester/compojure/wiki/Getting-Started

In particular...

(require '[compojure.handler as handler])

; define my-routes in here as normal
(handler/site my-routes)

I'm using some of this in my own projects. It works well, but I'll switch back to choosing ring middleware directly if I decide that I need to add or remove anything.

like image 43
Savanni D'Gerinel Avatar answered Oct 06 '22 01:10

Savanni D'Gerinel