Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Remove auto reload server sample, superceded by lein run-dev

  • Loading branch information...
commit efa8c9b82dc7593d32c47720826fab990467ab9e 1 parent e834da9
@rkneufeld rkneufeld authored
View
3  samples/auto-reload-server/.gitignore
@@ -1,3 +0,0 @@
-target/
-tmp/
-logs/
View
20 samples/auto-reload-server/README.md
@@ -1,20 +0,0 @@
-# auto-reload-server
-
-FIXME
-
-## Getting Started
-
-1. Start the application: `lein run`
-2. Go to [localhost:8080](http://localhost:8080/) to see: `Hello World!`
-3. Read your app's source code at src/auto_reload_server/service.clj. Explore the docs of functions
- that define routes and responses.
-4. Run your app's tests with `lein test`. Read the tests at test/auto_reload_server/service_test.clj.
-5. Learn more! See the [Links section below](#links).
-
-## Configuration
-
-To configure logging see config/logback.xml. By default, the app logs to stdout and logs/.
-To learn more about configuring Logback, read its [documentation](http://logback.qos.ch/documentation.html).
-
-## Links
-* [Other examples](https://github.com/pedestal/samples)
View
52 samples/auto-reload-server/config/logback.xml
@@ -1,52 +0,0 @@
-<!-- Logback configuration. See http://logback.qos.ch/manual/index.html -->
-<configuration scan="true" scanPeriod="10 seconds">
-
- <!-- Simple file output -->
- <appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
- <!-- encoder defaults to ch.qos.logback.classic.encoder.PatternLayoutEncoder -->
- <encoder>
- <pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern>
- </encoder>
-
- <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
- <!-- rollover daily -->
- <fileNamePattern>logs/auto-reload-server-%d{yyyy-MM-dd}.%i.log</fileNamePattern>
- <timeBasedFileNamingAndTriggeringPolicy
- class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
- <!-- or whenever the file size reaches 64 MB -->
- <maxFileSize>64 MB</maxFileSize>
- </timeBasedFileNamingAndTriggeringPolicy>
- </rollingPolicy>
-
- <!-- Safely log to the same file from multiple JVMs. Degrades performance! -->
- <prudent>true</prudent>
- </appender>
-
-
- <!-- Console output -->
- <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
- <!-- encoder defaults to ch.qos.logback.classic.encoder.PatternLayoutEncoder -->
- <encoder>
- <pattern>%-5level %logger{36} - %msg%n</pattern>
- </encoder>
- <!-- Only log level INFO and above -->
- <filter class="ch.qos.logback.classic.filter.ThresholdFilter">
- <level>INFO</level>
- </filter>
- </appender>
-
-
- <!-- Enable FILE and STDOUT appenders for all log messages.
- By default, only log at level INFO and above. -->
- <root level="INFO">
- <appender-ref ref="FILE" />
- <appender-ref ref="STDOUT" />
- </root>
-
- <!-- For loggers in the these namespaces, log at all levels. -->
- <logger name="user" level="ALL" />
- <!-- To log pedestal internals, enable this and change ThresholdFilter to DEBUG
- <logger name="pedestal" level="ALL" />
- -->
-
-</configuration>
View
54 samples/auto-reload-server/dev/dev.clj
@@ -1,54 +0,0 @@
-(ns dev
- (:require [io.pedestal.http :as bootstrap]
- [auto-reload-server.service :as service]
- [auto-reload-server.server :as server]
- [ns-tracker.core :as tracker]))
-
-(def service (-> service/service ;; start with production configuration
- (merge {:env :dev
- ;; do not block thread that starts web server
- ::bootstrap/join? false
- ;; reload routes on every request
- ::bootstrap/routes #(deref #'service/routes)
- ;; all origins are allowed in dev mode
- ::bootstrap/allowed-origins (constantly true)})
- (bootstrap/default-interceptors)
- (bootstrap/dev-interceptors)))
-
-(defn start
- [& [opts]]
- (server/create-server (merge service opts))
- (bootstrap/start server/service-instance))
-
-(defn stop
- []
- (bootstrap/stop server/service-instance))
-
-(defn restart
- []
- (stop)
- (start))
-
-(defn- ns-reload [track]
- (try
- (doseq [ns-sym (track)]
- (require ns-sym :reload))
- (catch Throwable e (.printStackTrace e))))
-
-(defn watch
- ([] (watch ["src"]))
- ([src-paths]
- (let [track (tracker/ns-tracker src-paths)
- done (atom false)]
- (doto
- (Thread. (fn []
- (while (not @done)
- (ns-reload track)
- (Thread/sleep 500))))
- (.setDaemon true)
- (.start))
- (fn [] (swap! done not)))))
-
-(defn -main [& args]
- (start)
- (watch))
View
5 samples/auto-reload-server/dev/user.clj
@@ -1,5 +0,0 @@
-(defn dev
- []
- (require 'dev)
- (in-ns 'dev)
- #_(dev/start))
View
25 samples/auto-reload-server/project.clj
@@ -1,25 +0,0 @@
-(defproject auto-reload-server "0.0.1-SNAPSHOT"
- :description "FIXME: write description"
- :url "http://example.com/FIXME"
- :license {:name "Eclipse Public License"
- :url "http://www.eclipse.org/legal/epl-v10.html"}
- :dependencies [[org.clojure/clojure "1.5.0"]
- [io.pedestal/pedestal.service "0.1.9-SNAPSHOT"]
-
- ;; Remove this line and uncomment the next line to
- ;; use Tomcat instead of Jetty:
- [io.pedestal/pedestal.jetty "0.1.9-SNAPSHOT"]
- ;; [io.pedestal/pedestal.tomcat "0.1.9-SNAPSHOT"]
-
- ;; auto-reload changes
- [ns-tracker "0.2.1"]
-
- ;; Logging
- [ch.qos.logback/logback-classic "1.0.7" :exclusions [org.slf4j/slf4j-api]]
- [org.slf4j/jul-to-slf4j "1.7.2"]
- [org.slf4j/jcl-over-slf4j "1.7.2"]
- [org.slf4j/log4j-over-slf4j "1.7.2"]]
- :profiles {:dev {:source-paths ["dev"]}}
- :min-lein-version "2.0.0"
- :resource-paths ["config", "resources"]
- :main ^{:skip-aot true} auto-reload-server.server)
View
31 samples/auto-reload-server/src/auto_reload_server/server.clj
@@ -1,31 +0,0 @@
-(ns auto-reload-server.server
- (:gen-class) ; for -main method in uberjar
- (:require [auto-reload-server.service :as service]
- [io.pedestal.http :as bootstrap]))
-
-(defonce service-instance nil)
-
-(defn create-server
- "Standalone dev/prod mode."
- [& [opts]]
- (alter-var-root #'service-instance
- (constantly (bootstrap/create-server (merge service/service opts)))))
-
-(defn -main [& args]
- (create-server)
- (bootstrap/start service-instance))
-
-
-;; Container prod mode for use with the io.pedestal.servlet.ClojureVarServlet class.
-
-(defn servlet-init [this config]
- (alter-var-root #'service-instance
- (constantly (bootstrap/create-servlet service/service)))
- (.init (::bootstrap/servlet service-instance) config))
-
-(defn servlet-destroy [this]
- (alter-var-root #'service-instance nil))
-
-(defn servlet-service [this servlet-req servlet-resp]
- (.service ^javax.servlet.Servlet (::bootstrap/servlet service-instance)
- servlet-req servlet-resp))
View
49 samples/auto-reload-server/src/auto_reload_server/service.clj
@@ -1,49 +0,0 @@
-(ns auto-reload-server.service
- (:require [io.pedestal.http :as bootstrap]
- [io.pedestal.http.route :as route]
- [io.pedestal.http.body-params :as body-params]
- [io.pedestal.http.route.definition :refer [defroutes]]
- [ring.util.response :as ring-resp]))
-
-(defn about-page
- [request]
- (ring-resp/response (format "Clojure %s" (clojure-version))))
-
-(defn home-page
- [request]
- (ring-resp/response "Hello World!"))
-
-(defroutes routes
- [[["/" {:get home-page}
- ;; Set default interceptors for /about and any other paths under /
- ^:interceptors [(body-params/body-params) bootstrap/html-body]
- ["/about" {:get about-page}]]]])
-
-;; You can use this fn or a per-request fn via io.pedestal.http.route/url-for
-(def url-for (route/url-for-routes routes))
-
-;; Consumed by auto-reload-server.server/create-server
-(def service {:env :prod
- ;; You can bring your own non-default interceptors. Make
- ;; sure you include routing and set it up right for
- ;; dev-mode. If you do, many other keys for configuring
- ;; default interceptors will be ignored.
- ;; :bootstrap/interceptors []
- ::bootstrap/routes routes
-
- ;; Uncomment next line to enable CORS support, add
- ;; string(s) specifying scheme, host and port for
- ;; allowed source(s):
- ;;
- ;; "http://localhost:8080"
- ;;
- ;;::boostrap/allowed-origins ["scheme://host:port"]
-
- ;; Root for resource interceptor that is available by default.
- ::bootstrap/resource-path "/public"
-
- ;; Either :jetty or :tomcat (see comments in project.clj
- ;; to enable Tomcat)
- ;;::bootstrap/host "localhost"
- ::bootstrap/type :jetty
- ::bootstrap/port 8080})
View
24 samples/auto-reload-server/test/auto_reload_server/service_test.clj
@@ -1,24 +0,0 @@
-(ns auto-reload-server.service-test
- (:require [clojure.test :refer :all]
- [io.pedestal.test :refer :all]
- [io.pedestal.http :as bootstrap]
- [auto-reload-server.service :as service]))
-
-(def service
- (::bootstrap/service-fn (bootstrap/create-servlet service/service)))
-
-(deftest home-page-test
- (is (=
- (:body (response-for service :get "/"))
- "Hello World!"))
- (is (=
- (:headers (response-for service :get "/"))
- {"Content-Type" "text/html;charset=UTF-8"})))
-
-(deftest about-page-test
- (is (.contains
- (:body (response-for service :get "/about"))
- "Clojure 1.5"))
- (is (=
- (:headers (response-for service :get "/about"))
- {"Content-Type" "text/html;charset=UTF-8"})))

0 comments on commit efa8c9b

Please sign in to comment.
Something went wrong with that request. Please try again.