Permalink
Browse files

Added jetty restart on OOM, will only work when blocking (ie from -ma…

…in, not when run inline).
  • Loading branch information...
amcnamara committed Dec 31, 2011
1 parent 758fdd9 commit f967795fc99455a5cfa020e5c19e66f9aa45147b
Showing with 10 additions and 4 deletions.
  1. +10 −4 src/foreclojure/core.clj
View
@@ -3,6 +3,7 @@
[compojure.handler :as handler]
[foreclojure.config :as config]
[sandbar.stateful-session :as session])
+ (:import [java.lang OutOfMemoryError])
(:use [compojure.core :only [defroutes routes GET]]
[foreclojure.static :only [static-routes welcome-page]]
[foreclojure.api :only [api-routes]]
@@ -97,10 +98,15 @@
(let [default-jetty-port 8080]
(defn run []
- (prepare-mongo)
- (register-heartbeat)
- (run-jetty (var app) {:join? *block-server*
- :port (get config :jetty-port default-jetty-port)})))
+ (try
+ (do
+ (prepare-mongo)
+ (register-heartbeat)
+ (run-jetty (var app) {:join? *block-server*
+ :port (get config :jetty-port default-jetty-port)}))
+ (catch OutOfMemoryError e
+ ;;TODO: log this?
+ (run)))))
(defn -main [& args]
(binding [*block-server* true]

0 comments on commit f967795

Please sign in to comment.