Created
January 18, 2012 21:33
-
-
Save techwhizbang/1635837 to your computer and use it in GitHub Desktop.
Super long running Clojure shell commands
This file contains hidden or 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
(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