Sha256: f966e70d8833e05a6a043b4c87120303bcec396e9e5290caf1702c402e2119d1

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 :dump 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 #{ROOT}/mongo --fork --logpath #{ROOT}/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.18 lib/zfben_rails_rake/tasks/mongodb.rb