|
@@ -1,20 +1,20 @@
|
|
(ns hello.handler
|
|
(ns hello.handler
|
|
- (:use hello.routes.home
|
|
|
|
- compojure.core)
|
|
|
|
- (:require [noir.util.middleware :as middleware]
|
|
|
|
|
|
+ (:require [compojure.core :refer [defroutes routes]]
|
|
|
|
+ [hello.routes.home :refer [home-routes]]
|
|
|
|
+ [hello.db.core :as db]
|
|
|
|
+ [hello.middleware
|
|
|
|
+ :refer [development-middleware production-middleware]]
|
|
|
|
+ [hello.session :as session]
|
|
[compojure.route :as route]
|
|
[compojure.route :as route]
|
|
[taoensso.timbre :as timbre]
|
|
[taoensso.timbre :as timbre]
|
|
- [taoensso.timbre.appenders.rotor :as rotor]))
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-(defroutes app-routes
|
|
|
|
- (route/resources "/")
|
|
|
|
- (route/not-found "Not Found"))
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-(defn destroy []
|
|
|
|
- (timbre/info "picture-gallery is shutting down"))
|
|
|
|
|
|
+ [taoensso.timbre.appenders.rotor :as rotor]
|
|
|
|
+ [selmer.parser :as parser]
|
|
|
|
+ [environ.core :refer [env]]
|
|
|
|
+ [cronj.core :as cronj]))
|
|
|
|
|
|
|
|
+(defroutes base-routes
|
|
|
|
+ (route/resources "/")
|
|
|
|
+ (route/not-found "Not Found"))
|
|
|
|
|
|
(defn init
|
|
(defn init
|
|
"init will be called once when
|
|
"init will be called once when
|
|
@@ -24,34 +24,34 @@
|
|
[]
|
|
[]
|
|
(timbre/set-config!
|
|
(timbre/set-config!
|
|
[:appenders :rotor]
|
|
[:appenders :rotor]
|
|
- {:min-level :info
|
|
|
|
- :enabled? true
|
|
|
|
- :async? false ; should be always false for rotor
|
|
|
|
|
|
+ {:min-level :info
|
|
|
|
+ :enabled? true
|
|
|
|
+ :async? false ; should be always false for rotor
|
|
:max-message-per-msecs nil
|
|
:max-message-per-msecs nil
|
|
- :fn rotor/appender-fn})
|
|
|
|
|
|
+ :fn rotor/appender-fn})
|
|
|
|
|
|
(timbre/set-config!
|
|
(timbre/set-config!
|
|
[:shared-appender-config :rotor]
|
|
[:shared-appender-config :rotor]
|
|
- {:path "{{sanitized}}.log" :max-size (* 512 1024) :backlog 10})
|
|
|
|
-
|
|
|
|
- (timbre/info "hello started successfully"))
|
|
|
|
|
|
+ {:path "hello.log" :max-size (* 512 1024) :backlog 10})
|
|
|
|
|
|
|
|
+ (if (env :dev) (parser/cache-off!))
|
|
|
|
+ (db/connect!)
|
|
|
|
+ ;;start the expired session cleanup job
|
|
|
|
+ (cronj/start! session/cleanup-job)
|
|
|
|
+ (timbre/info "\n-=[ hello started successfully"
|
|
|
|
+ (when (env :dev) "using the development profile") "]=-"))
|
|
|
|
|
|
(defn destroy
|
|
(defn destroy
|
|
"destroy will be called when your application
|
|
"destroy will be called when your application
|
|
shuts down, put any clean up code here"
|
|
shuts down, put any clean up code here"
|
|
[]
|
|
[]
|
|
- (timbre/info "hello is shutting down..."))
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-(def app (middleware/app-handler
|
|
|
|
- ;; add your application routes here
|
|
|
|
- [home-routes app-routes]
|
|
|
|
- ;; add custom middleware here
|
|
|
|
- :middleware []
|
|
|
|
- ;; add access rules here
|
|
|
|
- :access-rules []
|
|
|
|
- ;; serialize/deserialize the following data formats
|
|
|
|
- ;; available formats:
|
|
|
|
- ;; :json :json-kw :yaml :yaml-kw :edn :yaml-in-html
|
|
|
|
- :formats [:json-kw :edn]))
|
|
|
|
|
|
+ (timbre/info "hello is shutting down...")
|
|
|
|
+ (cronj/shutdown! session/cleanup-job)
|
|
|
|
+ (timbre/info "shutdown complete!"))
|
|
|
|
+
|
|
|
|
+(def app
|
|
|
|
+ (-> (routes
|
|
|
|
+ home-routes
|
|
|
|
+ base-routes)
|
|
|
|
+ development-middleware
|
|
|
|
+ production-middleware))
|