fix dev mode not reloading code changes
hacky fix due to the fact that we load the app config at a time later then when the namespace is first loaded, so our old wrap-env-middleware cannot work as-is. and then immutant's own run function alternative that can be used to run the server in dev mode has some super annoying behaviour that can't be turned off (opening a browser on startup... who the *fuck* actually likes this behaviour? don't you people keep a browser open all the time when you're working on web dev anyway?)
This commit is contained in:
parent
058d587903
commit
ce4c2c1a39
|
@ -7,7 +7,6 @@
|
||||||
[immutant.web :as immutant]
|
[immutant.web :as immutant]
|
||||||
[ring.middleware.defaults :refer [wrap-defaults site-defaults]]
|
[ring.middleware.defaults :refer [wrap-defaults site-defaults]]
|
||||||
[ring.middleware.format :refer [wrap-restful-format]]
|
[ring.middleware.format :refer [wrap-restful-format]]
|
||||||
[ring.middleware.reload :refer [wrap-reload]]
|
|
||||||
[taoensso.sente.server-adapters.immutant :refer [sente-web-server-adapter]]
|
[taoensso.sente.server-adapters.immutant :refer [sente-web-server-adapter]]
|
||||||
|
|
||||||
[mtgcoll.cli :refer [parse-cli-args]]
|
[mtgcoll.cli :refer [parse-cli-args]]
|
||||||
|
@ -45,12 +44,6 @@
|
||||||
|
|
||||||
(log/info "Application stopped."))
|
(log/info "Application stopped."))
|
||||||
|
|
||||||
(defn wrap-env-middleware
|
|
||||||
[handler]
|
|
||||||
(if (config/get :dev?)
|
|
||||||
(-> handler (wrap-reload))
|
|
||||||
handler))
|
|
||||||
|
|
||||||
(def handler
|
(def handler
|
||||||
(-> (routes
|
(-> (routes
|
||||||
collection-routes
|
collection-routes
|
||||||
|
@ -58,7 +51,6 @@
|
||||||
main-page-routes
|
main-page-routes
|
||||||
(route/resources "/")
|
(route/resources "/")
|
||||||
(route/not-found "not found"))
|
(route/not-found "not found"))
|
||||||
(wrap-env-middleware)
|
|
||||||
(wrap-restful-format :formats [:json-kw])
|
(wrap-restful-format :formats [:json-kw])
|
||||||
(sente/wrap-sente "/chsk")
|
(sente/wrap-sente "/chsk")
|
||||||
(wrap-defaults (assoc-in site-defaults [:security :anti-forgery] false))))
|
(wrap-defaults (assoc-in site-defaults [:security :anti-forgery] false))))
|
||||||
|
@ -66,15 +58,22 @@
|
||||||
(defn start-server!
|
(defn start-server!
|
||||||
[]
|
[]
|
||||||
(init)
|
(init)
|
||||||
(immutant/run
|
(let [options (merge
|
||||||
#'handler
|
{:port 8080
|
||||||
(merge
|
:host "localhost"
|
||||||
{:port 8080
|
:path "/"
|
||||||
:host "localhost"
|
:virtual-host nil
|
||||||
:path "/"
|
:dispatch? true}
|
||||||
:virtual-host nil
|
(config/get :web))]
|
||||||
:dispatch? true}
|
(if (config/get :dev?)
|
||||||
(config/get :web))))
|
; why the fuck would anyone assume that if you are running in "development mode" you automatically
|
||||||
|
; want a new browser window/tab to be opened each time the web server is started? AND not provide an
|
||||||
|
; option to disable this annoying-as-fuck behaviour.
|
||||||
|
; i mean, jesus christ, it's obviously _not_ possible that i might already have a browser open that i
|
||||||
|
; might prefer to keep reusing ... !
|
||||||
|
(with-redefs [clojure.java.browse/browse-url (fn [_])]
|
||||||
|
(immutant/run-dmc #'handler options))
|
||||||
|
(immutant/run #'handler options))))
|
||||||
|
|
||||||
(defn stop-server!
|
(defn stop-server!
|
||||||
[]
|
[]
|
||||||
|
|
Loading…
Reference in a new issue