Skip to content

Instantly share code, notes, and snippets.

@techwhizbang
Created January 18, 2012 21:33
Show Gist options
  • Save techwhizbang/1635837 to your computer and use it in GitHub Desktop.
Save techwhizbang/1635837 to your computer and use it in GitHub Desktop.
Super long running Clojure shell commands
(ns my-app.db.prepare
(:use [clojure.java.shell :only [sh]]))
(defn -main []
"Will create the database if it does not exist yet for the specified environment"
(let [db-name "my_db"
db-user "root"
db-pass ""]
(print (:out (sh "mysql" (str "-u" db-user) "--verbose" (str "-p" db-pass) (str "--execute=drop database " db-name))))
(print (:out (sh "mysql" (str "-u" db-user) "--verbose" (str "-p" db-pass) (str "--execute=create database " db-name))))
; long standing bug that holds up the process for an additional 60 secs http://dev.clojure.org/jira/browse/CLJ-124
; adding (shutdown-agents) fixes the long running problem in a huge way!
(shutdown-agents)
))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment