Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Catching OOM from jetty #199

Merged
merged 1 commit into from Dec 31, 2011
Jump to file or symbol
Failed to load files and symbols.
+10 −4
Split
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]