Skip to content

Instantly share code, notes, and snippets.

@levity
Created March 25, 2014 22:55
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save levity/9773299 to your computer and use it in GitHub Desktop.
Save levity/9773299 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
@nikilster
Copy link

What does the namespace :mosql do?

@nikilster
Copy link

Thanks so much!

@levity
Copy link
Author

levity commented Mar 27, 2014

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