Created
April 1, 2010 23:07
-
-
Save peleteiro/352495 to your computer and use it in GitHub Desktop.
rake task to install and run mongodb
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
desc "Runs mongodb" | |
task :mongodb => %w{mongodb:install mongodb:run} | |
namespace :mongodb do | |
task :install do | |
next if File.exist?("vendor/mongodb/1.4.0") | |
if RUBY_PLATFORM =~ /darwin/ # OSX | |
system <<-bash | |
mkdir -p #{Rails.root}/vendor/mongodb/data | |
curl http://downloads.mongodb.org/osx/mongodb-osx-x86_64-1.4.0.tgz -o /tmp/mongodb.tgz | |
tar -C #{Rails.root}/vendor/mongodb -xvzf /tmp/mongodb.tgz | |
mv vendor/mongodb/mongodb-osx-x86_64-1.4.0 #{Rails.root}/vendor/mongodb/1.4.0 | |
bash | |
elsif RUBY_PLATFORM =~ /linux/ # Linux | |
system <<-bash | |
mkdir -p #{Rails.root}/vendor/mongodb/data | |
curl http://downloads.mongodb.org/osx/mongodb-linux-i686-1.4.0.tgz -o /tmp/mongodb.tgz | |
tar -C #{Rails.root}/vendor/mongodb -xvzf /tmp/mongodb.tgz | |
mv vendor/mongodb/mongodb-linux-i686-1.4.0 #{Rails.root}/vendor/mongodb/1.4.0 | |
bash | |
else | |
puts "OSX (Snow Leopard) or Linux only" | |
next | |
end | |
end | |
task :run do | |
if File.exists?("/tmp/mongodb.dtach") | |
system "dtach -a /tmp/mongodb.dtach" | |
else | |
system "dtach -n /tmp/mongodb.dtach #{Rails.root}/vendor/mongodb/1.4.0/bin/mongod --dbpath #{Rails.root}/vendor/mongodb/data" | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment