Created
April 30, 2012 13:13
-
-
Save wtnabe/2558255 to your computer and use it in GitHub Desktop.
mongo task for rails ( put this task file as lib/tasks/mongo.rake )
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
# -*- mode: ruby -*- | |
include FileUtils::Verbose | |
@root = File.expand_path( File.dirname(__FILE__) + '/../../' ) | |
namespace :mongo do | |
desc 'prepare' | |
task :prepare do | |
dbpath = "#{@root}/db/mongodb" | |
mkdir( dbpath ) unless File.exist? dbpath | |
conf = File.join( @root, 'config', 'mongo_develop.conf.erb' ) | |
if ( not File.exist? conf ) | |
open( conf, 'w' ) { |f| | |
f.puts <<'EOD' | |
<% root = File.expand_path( File.dirname(__FILE__) + '/../' ) %> | |
dbpath = <%= "#{root}/db/mongodb" %> | |
logpath = <%= "#{root}/log/mongodb.log" %> | |
EOD | |
} | |
puts "created #{conf} ." | |
end | |
end | |
desc 'start mongod' | |
task :start do | |
conf = File.join( @root, 'config', 'mongo_develop.conf' ) | |
sh <<EOD | |
bundle exec erubis #{conf}.erb > #{conf} | |
mongod -f #{conf} | |
EOD | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
sample mongo_develop.conf.erb