How to stop all servers?

9 views
Skip to first unread message

Nicolas Buduroi

unread,
Oct 17, 2009, 9:25:10 PM10/17/09
to Compojure
Hi, While working on Compojure source code and testing a patch for
Ring adapters, I realized it would be great to have a way to shutdown
all currently open servers. I know this isn't that useful for normal
Compojure development and I haven't yet looked into how to do it, but
is there a simple way to do this?

Thanks

- budu

Adrian Cuthbertson

unread,
Oct 17, 2009, 11:37:02 PM10/17/09
to comp...@googlegroups.com
I usually keep track of jetty instances in a ref;

(def *jty* (ref {}))

(defn start-jty [port]
(let [srvr (jetty-server :port port)]
; define servlets, etc here
(.start srvr)
(dosync (alter *jty* assoc port srvr))))

(defn shut-jty [port]
(.stop (@*jty* port))
(dosync (alter *jty* dissoc port)))

You could then just loop on the entries in *jty* and shut them all in one go.

Regards, Adrian.

Nicolas Buduroi

unread,
Oct 18, 2009, 1:47:04 PM10/18/09
to Compojure
I must say that's a great way of doing it. It would be great to have
it built into Compojure, I'll see what I can do.

On Oct 17, 11:37 pm, Adrian Cuthbertson <adrian.cuthbert...@gmail.com>
wrote:
> I usually keep track of jetty instances in a ref;
>
> (def *jty* (ref {}))
>
> (defn start-jty [port]
>   (let [srvr (jetty-server :port port)]
>     ; define servlets, etc here
>     (.start srvr)
>     (dosync (alter *jty* assoc port srvr))))
>
> (defn shut-jty [port]
>   (.stop (@*jty* port))
>   (dosync (alter *jty* dissoc port)))
>
> You could then just loop on the entries in *jty* and shut them all in one go.
>
> Regards, Adrian.
>

Nicolas Buduroi

unread,
Oct 18, 2009, 5:38:03 PM10/18/09
to Compojure
I've made a patch to have this feature built into Compojure. It's
available in my Compojure repo on github, but is integrated in the
adapters namespace that is not yet committed in the main Compojure
repo.

I've also found a problem with grizzly servers while testing this
feature. If you restart a grizzly server, it loose all its handlers.
I've not yet looked into the cause for this behavior, does someone
have an idea about what is happening?
Reply all
Reply to author
Forward
0 new messages