Created
March 25, 2014 22:55
-
-
Save levity/9773299 to your computer and use it in GitHub Desktop.
Rake task for MoSQL on Heroku
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
# This is a simplified version of what we're using in production for drinksoma.com | |
namespace :mosql do | |
task :run => :environment do | |
conf_path = Rails.root.join('config', 'collections.yml') | |
cmd = "mosql -c #{conf_path} --sql #{ENV['MOSQL_POSTGRES_URI']} --mongo #{ENV['MOSQL_MONGO_URI']}" | |
IO.popen(cmd) do |child| | |
trap('TERM') { Process.kill 'INT', child.pid } | |
$stdout.sync = true | |
while line = child.gets | |
puts line | |
end | |
puts child.read | |
end | |
end | |
end |
Thanks so much!
namespace :mosql
is part of the Rake DSL; it makes it so I can call the task from the command line like rake mosql:run
.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
What does the namespace :mosql do?