Skip to content

Commit

Permalink
Update to work with latest tomcat crate
Browse files Browse the repository at this point in the history
  • Loading branch information
hugoduncan committed Aug 25, 2011
1 parent ebc0b27 commit 8a7c02e
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 35 deletions.
9 changes: 7 additions & 2 deletions project.clj
Expand Up @@ -4,13 +4,18 @@
[org.clojure/clojure-contrib "1.2.0"] [org.clojure/clojure-contrib "1.2.0"]
[net.cgrand/moustache "1.0.0"] [net.cgrand/moustache "1.0.0"]
[ring "0.3.7"] [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.cloudhoist/pallet-crates-all "0.5.0"]
[org.jclouds/jclouds-all "1.0.0"] [org.jclouds/jclouds-all "1.0.0"]
[org.jclouds.driver/jclouds-jsch "1.0.0"]] [org.jclouds.driver/jclouds-jsch "1.0.0"]]


:dev-dependencies [[uk.org.alienscience/leiningen-war "0.0.3"] :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"]] [vmfest "0.2.3"]]


:repositories {"sonatype" :repositories {"sonatype"
Expand Down
57 changes: 36 additions & 21 deletions src/servlet_test/ops/crate.clj
Expand Up @@ -10,24 +10,39 @@
(defn tomcat-deploy (defn tomcat-deploy
"Deploys the specified .war file to tomcat. An optional :port kwarg "Deploys the specified .war file to tomcat. An optional :port kwarg
defines the port that tomcat will serve on (defaults to 80)." defines the port that tomcat will serve on (defaults to 80)."
[pallet-request warfile & {:keys [port] :or {port 80}}] [session warfile]
(pallet.action.service/with-restart pallet-request "tomcat*" (->
(default/write "tomcat6" session
; configure tomcat's heap to utilize 2/3 of machine's total memory (pallet.action.service/with-restart "tomcat*"
:JAVA_OPTS (->> pallet-request (tomcat/deploy "ROOT" :local-file warfile :clear-existing true))))
:target-node
.getHardware (defn tomcat-server
.getRam [& {:keys [port] :or {port 80}}]
(* 0.66) (tomcat/server
int :shutdown "SHUTDOWN"
(format "-Xmx%sm")) (tomcat/service
; allow tomcat to run on ports < 1024 (tomcat/engine "catalina" "host" (tomcat/valve :request-dumper))
:AUTHBIND "yes") (tomcat/connector
(tomcat/server-configuration :port (str port) :protocol "HTTP/1.1"
(tomcat/server :port port :connectionTimeout "20000"
(tomcat/service :redirectPort "8443"))))
(tomcat/engine "catalina" "host" (tomcat/valve :request-dumper))
(tomcat/connector :port (str port) :protocol "HTTP/1.1" (defn tomcat-config
:connectionTimeout "20000" [session]
:redirectPort "8443")))) (->
(tomcat/deploy "ROOT" :local-file warfile :clear-existing true))) 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")))
33 changes: 21 additions & 12 deletions src/servlet_test/ops/nodes.clj
Expand Up @@ -25,27 +25,36 @@


(def nodespec (pallet.core/node-spec (def nodespec (pallet.core/node-spec
:image {:os-family :ubuntu :image {:os-family :ubuntu
:os-description-matches "10.10"} :os-description-matches "10.10"}
:hardware {:min-ram 512 :hardware {:min-ram 512
:hardware-id "t1.micro"} :hardware-id "t1.micro"
;; can optionally require cloud-specific images and node sizes if you like }
;; (strongly recommended for real usage!) ;; can optionally require cloud-specific images and node sizes if you like
;; :image-id "us-east-1/ami-508c7839" ;; (strongly recommended for real usage!)
;; :hardware-id "m1.small" ;; :image-id "us-east-1/ami-508c7839"
:network {:inbound-ports [22 80]})) ;; :hardware-id "m1.small"
:network {:inbound-ports [22 80]}))

(def tomcat-settings (tomcat/settings-map {:version 6}))


(def appserver (def appserver
(pallet.core/server-spec (pallet.core/server-spec
:phases {:bootstrap (pallet.phase/phase-fn :phases {:bootstrap (pallet.phase/phase-fn
(admin/automated-admin-user)) (admin/automated-admin-user))
:settings (fn [session]
(tomcat/settings
session
(assoc tomcat-settings
:server (webdeploy-crate/tomcat-server))))
:configure (pallet.phase/phase-fn :configure (pallet.phase/phase-fn
(pallet.crate.java/java :openjdk) (pallet.crate.java/java :openjdk)
(tomcat/tomcat)) (tomcat/install)
(webdeploy-crate/tomcat-config))
:deploy (pallet.phase/phase-fn :deploy (pallet.phase/phase-fn
(webdeploy-crate/tomcat-deploy warfile-path))} (webdeploy-crate/tomcat-deploy warfile-path))}))
:node-spec nodespec))


(def groupserver (def groupserver
(pallet.core/group-spec (pallet.core/group-spec
"AWS Group" "AWS-Group"
:extends appserver)) :extends appserver
:node-spec nodespec))

0 comments on commit 8a7c02e

Please sign in to comment.