-
-
Save SiriusDely/d165ac25e560262a163a8b0e127cf80d 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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment