Skip to content

Instantly share code, notes, and snippets.

@SiriusDely
Forked from levity/mosql.rake
Created September 15, 2020 14:55
Show Gist options
  • Save SiriusDely/d165ac25e560262a163a8b0e127cf80d to your computer and use it in GitHub Desktop.
Save SiriusDely/d165ac25e560262a163a8b0e127cf80d to your computer and use it in GitHub Desktop.
Rake task for MoSQL on Heroku
# 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