This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; Pallet 0.3.0-SNAPSHOT | |
;; nodes.clj | |
(def service | |
(compute/compute-service "node-list" | |
:node-list [(node-list/make-node "virtualbox" "server-all" | |
"10.0.1.14" :ubuntu)])) | |
(core/defnode the-server | |
"One server to run everything (servlet, database, nginx, etc)." |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
David-Santiagos-Computer:servlet David$ cake pallet lift com.mysite.deploy.nodes/the-server | |
Oct 17, 2010 7:47:10 PM clojure.contrib.logging$impl_write_BANG_ invoke | |
INFO: retrieving nodes | |
Oct 17, 2010 7:47:10 PM clojure.contrib.logging$impl_write_BANG_ invoke | |
INFO: apply-phase :pre-configure for :the-server with 1 nodes | |
Oct 17, 2010 7:47:10 PM clojure.contrib.logging$impl_write_BANG_ invoke | |
INFO: apply-phase :configure for :the-server with 1 nodes | |
Oct 17, 2010 7:47:10 PM clojure.contrib.logging$impl_write_BANG_ invoke | |
INFO: Connecting to 10.0.1.14 port 22 | |
Oct 17, 2010 7:47:10 PM clojure.contrib.logging$impl_write_BANG_ invoke |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
David-Santiagos-Computer:servlet David$ cake pallet lift com.davidsantiago.deploy.nodes/the-server | |
Oct 18, 2010 10:59:55 PM clojure.contrib.logging$impl_write_BANG_ invoke | |
INFO: retrieving nodes | |
Oct 18, 2010 10:59:55 PM clojure.contrib.logging$impl_write_BANG_ invoke | |
INFO: apply-phase :pre-configure for :the-server with 1 nodes | |
Oct 18, 2010 10:59:55 PM clojure.contrib.logging$impl_write_BANG_ invoke | |
INFO: apply-phase :configure for :the-server with 1 nodes | |
Oct 18, 2010 10:59:55 PM clojure.contrib.logging$impl_write_BANG_ invoke | |
INFO: Connecting to 10.0.1.14 port 22 | |
Oct 18, 2010 10:59:55 PM clojure.contrib.logging$impl_write_BANG_ invoke |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defn postgresql-script | |
"Execute a postgresql script. | |
Options for how this script should be run: | |
:as-user username - Run this script having sudoed to this (system) user. Default: postgres" | |
[request sql-script & {:keys [as-user] | |
:as options | |
:or {as-user "postgres"}}] | |
(-> request | |
(exec-script/exec-checked-script | |
"PostgreSQL temp command file" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2010-10-29 22:17:05,273 INFO [pallet.core] (Thread-1) apply-phase :after-configure for :the-server with 1 nodes | |
2010-10-29 22:19:25,130 DEBUG [pallet.main-invoker] (Thread-1) OS Mac OS X 10.6.4 | |
2010-10-29 22:19:25,130 DEBUG [pallet.main-invoker] (Thread-1) Arch i386 | |
2010-10-29 22:19:25,131 DEBUG [pallet.main-invoker] (Thread-1) Admin user david | |
2010-10-29 22:19:25,131 DEBUG [pallet.main-invoker] (Thread-1) private-key-path /Users/David/.ssh/id_rsa true | |
2010-10-29 22:19:25,131 DEBUG [pallet.main-invoker] (Thread-1) public-key-path /Users/David/.ssh/id_rsa.pub true | |
2010-10-29 22:19:25,132 DEBUG [pallet.main-invoker] (Thread-1) Running as null@null | |
2010-10-29 22:19:25,143 TRACE [pallet.core] (Thread-1) lift* phases [] | |
2010-10-29 22:19:25,143 INFO [pallet.core] (Thread-1) retrieving nodes |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defn ensure-database-exists | |
[request db-name & rest] | |
(-> request | |
(resource-when/resource-when | |
(= 0 @(psql "-t -c" | |
~(format "\"select count(1) from pg_database where datname='%s'\"" | |
db-name))) | |
(apply create-database request db-name rest)))) | |
;; Throws a stack trace complaining about too many args (5) to PersistentHashMap. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; My two attempts. The first is to make create-database ignore the error return | |
;; with chain-or. I can't get anything to compile here. Have tried with/without | |
;; stevedore/script, with/without ~(apply...). | |
;; Second attempt: ensure-database-exists function. Uses a defscript. This will | |
;; output the if statement desired, but at a seemingly random place earlier in the | |
;; script unrelated to the conditional. It will also not escape as-user or db-name, | |
;; although it will escape the (format ...). | |
(defn create-database |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defn maven-artifact | |
"Copy a jar to a filesystem location from a maven repo. Artifacts are a sequence | |
consisting of group, artifact, and version. Doesn't support SNAPSHOTS right now." | |
[request dir-path maven-repo-url artifacts] | |
(let [[group artifact version] (first artifacts)] | |
(if (not (and group artifact version)) | |
;; Ran out of artifacts, return the request. | |
request | |
(let [file-name (str artifact "-" version ".jar") | |
group-path (join "/" (split group #"\.")) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; When the wrap! is as below, the admin functions are properly wrapped, but the | |
;; site functions will error 500 with an NPE on session.clj:47. If I comment it and | |
;; uncomment the wrap! at the bottom, then the site URLs will work, but the admin | |
;; functions will not successfully log in, despite having the form parameters and | |
;; session in apparently the correct place. In fact, the post request to login is | |
;; identical in both cases, but it will only work if the code is as below. | |
;; | |
;; Ideally, I'd like to be able to break my routes into manageable chunks, compose | |
;; them, and then just wrap! once. In my reading of the source, I thought routes | |
;; were just functions that take a request and return a response, so shouldn't |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
David-Santiagos-Computer:servlet David$ cake pallet nodes -- -P virtualbox | |
INFO jclouds - extensions (:log4j :ssh) | |
David-Santiagos-Computer:servlet David$ cake pallet lift com.battletheory.deploy.nodes/server :deploy @dev -- -P virtualbox | |
INFO jclouds - extensions (:log4j :ssh) | |
INFO core - retrieving nodes | |
INFO core - apply-phase :pre-deploy for :server with 0 nodes | |
INFO core - apply-phase :deploy for :server with 0 nodes | |
INFO core - apply-phase :after-deploy for :server with 0 nodes |