When I first wrote a Clojure web app, I followed a lot of the basic tutorials out there, and those tend to create a lot of global vars. So, for instance, I used the "defroutes" macro from Compojure, which left me with a global "app-routes" var.
But lately I wanted to switch to a style that would allow me to call a "start" function that would reboot my app, so that I could more easily re-start from the REPL, without shutting down the JVM and starting over again. So I moved all of my global var stuff inside my start function, like this: (defn start [map-of-config] (try (let [port (if (nil? (:port map-of-config)) 34000 (Integer/parseInt (:port map-of-config))) app-routes (routes (ANY "/" [] homepage) (GET "/v0.2/token" [] token) (GET "/v0.2/errors" [] errors) (ANY "/v0.2/:token/:name-of-collection/object-id/:object-id" request query/fetch) (ANY "/v0.2/:token/:name-of-collection/:document-id" request query/fetch) (ANY "/v0.2/:token/:name-of-collection/" request query/fetch) (route/resources "/") (route/not-found "Page not found. Check the http verb that you used (GET, POST, PUT, DELETE) and make sure you put a collection name in the URL, and possibly also a document ID. Also, all requests should go to an URL that starts with /v0.2")) app (-> app-routes (wrap-json-response) (middleware/wrap-objectid-to-str) (middleware/wrap-prepare-message) (middleware/wrap-error-post-with-document-id) (middleware/wrap-malformed?) (middleware/wrap-check-content-type) (middleware/wrap-transaction-id) (middleware/wrap-token) (middleware/wrap-token-check) (middleware/wrap-cors-headers) (wrap-keyword-params) (wrap-multipart-params) (wrap-nested-params) (wrap-params) (wrap-json-body {:keywords? true}) (wrap-content-type)) jetty (run-jetty app {:port port :join? false :max-threads 5000})] ;; we want to reboot this app from the REPL, so the start function needs to overwrite "server" (println (str "The port number we will listen to: " port)) (timbre/log :trace (str "The port number we will listen to: " port)) (swap! server (fn [old-value] jetty))) (catch Exception e (println e)))) This does not throw an exception. And, once it is running, if I do this: netstat -ntlp | grep LISTEN then I can see there is suddenly an app listening on port 34000: tcp 0 0 127.0.0.1:27017 0.0.0.0:* LISTEN - tcp 0 0 127.0.0.1:3306 0.0.0.0:* LISTEN - tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN - tcp 0 0 127.0.0.1:5432 0.0.0.0:* LISTEN - tcp6 0 0 :::34000 :::* LISTEN 12835/java tcp6 0 0 :::80 :::* LISTEN - tcp6 0 0 :::22 :::* LISTEN - But if I point my browser at this port, I get nothing. I do not get an exception, I also see nothing printed at the terminal. I have gone through and added print statements to all of my middleware, but I can not see any of the print statements in the terminal. I am wondering if it is possible for a request to come in and get swallowed entirely, without even triggering the middleware? -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups "Clojure" group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.