Sha256: 14623f3eb5f302f8b14a211bfe3c9bb3364f39754e7c0707533d2a959b0a261b

Contents?: true

Size: 1.04 KB

Versions: 1

Compression:

Stored size: 1.04 KB

Contents

if File.exist?(ROOT + '/config/mongoid.yml')
  config = YAML.load(File.read(ROOT + '/config/mongoid.yml'))
  namespace :mongodb do
    backup = "mongodump --host #{config['production']['host']} --port #{config['production']['port']}"
    desc backup
    task :backup do
      sys backup
    end

    restore = "mongorestore --host #{config['production']['host']} --port #{config['production']['port']}"
    desc restore
    task :restore do
      sys restore
    end

    desc 'Start Mongodb'
    task :start do
      sys "mkdir #{ROOT}/mongo" unless File.exists?(ROOT + '/mongo')
      sys "mongod --nohttpinterface --nojournal --port #{config['production']['port']} --bind_ip #{config['production']['host']} --dbpath #{path}/mongo --fork --logpath #{path}/log/mongodb.log"
    end

    desc 'Stop Mongodb'
    task :stop do
      path = ROOT + '/mongo/mongod.lock'
      if File.exists?(path)
        sys "kill `cat #{path}`"
        sys 'rm ' + path
      end
    end

    desc 'Clear mongo folder'
    task :clear do
      sys 'rm -r mongo/*'
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
zfben_rails_rake-0.0.14 lib/zfben_rails_rake/tasks/mongodb.rb