Permalink
Browse files

Update to work with latest tomcat crate

  • Loading branch information...
1 parent ebc0b27 commit 8a7c02ec85981ef9c322cc4d7bb111cd00328b53 @hugoduncan committed Aug 25, 2011
Showing with 64 additions and 35 deletions.
  1. +7 −2 project.clj
  2. +36 −21 src/servlet_test/ops/crate.clj
  3. +21 −12 src/servlet_test/ops/nodes.clj
View
@@ -4,13 +4,18 @@
[org.clojure/clojure-contrib "1.2.0"]
[net.cgrand/moustache "1.0.0"]
[ring "0.3.7"]
- [org.cloudhoist/pallet "0.6.2"]
+ [org.cloudhoist/pallet "0.6.3-SNAPSHOT"]
+ [org.cloudhoist/automated-admin-user "0.5.1-SNAPSHOT"]
+ [org.cloudhoist/etc-default "0.5.0"]
+ [org.cloudhoist/java "0.5.1"]
+ [org.cloudhoist/tomcat "0.6.1-SNAPSHOT"]
[org.cloudhoist/pallet-crates-all "0.5.0"]
[org.jclouds/jclouds-all "1.0.0"]
[org.jclouds.driver/jclouds-jsch "1.0.0"]]
:dev-dependencies [[uk.org.alienscience/leiningen-war "0.0.3"]
- [org.cloudhoist/pallet-lein "0.4.0"]
+ [org.cloudhoist/pallet-lein "0.4.1"]
+ [lein-ring "0.4.5"] ; https://github.com/weavejester/lein-ring
[vmfest "0.2.3"]]
:repositories {"sonatype"
@@ -10,24 +10,39 @@
(defn tomcat-deploy
"Deploys the specified .war file to tomcat. An optional :port kwarg
defines the port that tomcat will serve on (defaults to 80)."
- [pallet-request warfile & {:keys [port] :or {port 80}}]
- (pallet.action.service/with-restart pallet-request "tomcat*"
- (default/write "tomcat6"
- ; configure tomcat's heap to utilize 2/3 of machine's total memory
- :JAVA_OPTS (->> pallet-request
- :target-node
- .getHardware
- .getRam
- (* 0.66)
- int
- (format "-Xmx%sm"))
- ; allow tomcat to run on ports < 1024
- :AUTHBIND "yes")
- (tomcat/server-configuration
- (tomcat/server :port port
- (tomcat/service
- (tomcat/engine "catalina" "host" (tomcat/valve :request-dumper))
- (tomcat/connector :port (str port) :protocol "HTTP/1.1"
- :connectionTimeout "20000"
- :redirectPort "8443"))))
- (tomcat/deploy "ROOT" :local-file warfile :clear-existing true)))
+ [session warfile]
+ (->
+ session
+ (pallet.action.service/with-restart "tomcat*"
+ (tomcat/deploy "ROOT" :local-file warfile :clear-existing true))))
+
+(defn tomcat-server
+ [& {:keys [port] :or {port 80}}]
+ (tomcat/server
+ :shutdown "SHUTDOWN"
+ (tomcat/service
+ (tomcat/engine "catalina" "host" (tomcat/valve :request-dumper))
+ (tomcat/connector
+ :port (str port) :protocol "HTTP/1.1"
+ :connectionTimeout "20000"
+ :redirectPort "8443"))))
+
+(defn tomcat-config
+ [session]
+ (->
+ session
+ (tomcat/server-configuration)
+ (default/write "tomcat6"
+ ;; configure tomcat's heap to utilize 2/3 of machine's
+ ;; total memory
+ :JAVA_OPTS (try (->> session
+ :target-node
+ .getHardware
+ .getRam
+ (* 0.66)
+ int
+ (format "-Xmx%sm"))
+ (catch Exception e
+ "-Xmx512m"))
+ ; allow tomcat to run on ports < 1024
+ :AUTHBIND "yes")))
@@ -25,27 +25,36 @@
(def nodespec (pallet.core/node-spec
:image {:os-family :ubuntu
- :os-description-matches "10.10"}
+ :os-description-matches "10.10"}
:hardware {:min-ram 512
- :hardware-id "t1.micro"}
- ;; can optionally require cloud-specific images and node sizes if you like
- ;; (strongly recommended for real usage!)
- ;; :image-id "us-east-1/ami-508c7839"
- ;; :hardware-id "m1.small"
- :network {:inbound-ports [22 80]}))
+ :hardware-id "t1.micro"
+ }
+ ;; can optionally require cloud-specific images and node sizes if you like
+ ;; (strongly recommended for real usage!)
+ ;; :image-id "us-east-1/ami-508c7839"
+ ;; :hardware-id "m1.small"
+ :network {:inbound-ports [22 80]}))
+
+(def tomcat-settings (tomcat/settings-map {:version 6}))
(def appserver
(pallet.core/server-spec
:phases {:bootstrap (pallet.phase/phase-fn
(admin/automated-admin-user))
+ :settings (fn [session]
+ (tomcat/settings
+ session
+ (assoc tomcat-settings
+ :server (webdeploy-crate/tomcat-server))))
:configure (pallet.phase/phase-fn
(pallet.crate.java/java :openjdk)
- (tomcat/tomcat))
+ (tomcat/install)
+ (webdeploy-crate/tomcat-config))
:deploy (pallet.phase/phase-fn
- (webdeploy-crate/tomcat-deploy warfile-path))}
- :node-spec nodespec))
+ (webdeploy-crate/tomcat-deploy warfile-path))}))
(def groupserver
(pallet.core/group-spec
- "AWS Group"
- :extends appserver))
+ "AWS-Group"
+ :extends appserver
+ :node-spec nodespec))

0 comments on commit 8a7c02e

Please sign in to comment.