Sha256: 55dca0f91afa041e3706ee8c53df5c212aa1d51f9597a6b9906b69a6756f664d

Contents?: true

Size: 922 Bytes

Versions: 3

Compression:

Stored size: 922 Bytes

Contents

require File.expand_path(File.dirname(__FILE__) + '/../utilities')
require File.expand_path(File.dirname(__FILE__) + '/install')

Capistrano::Configuration.instance(true).load do
  set :mongodb_log, "/var/log/mongodb.log"

  namespace :mongodb do
    desc "Starts the mongodb server"
    task :start, :role => :app do
      sudo "#{mongodb_bin_path}/bin/mongod --fork --logpath #{mongodb_log} --logappend --dbpath #{mongodb_data_path}"
    end

    desc "Stop the mongodb server"
    task :stop, :role => :app do
      pid = capture("ps -o pid,command ax | grep mongod | awk '!/awk/ && !/grep/ {print $1}'")
      sudo "kill -INT #{pid}" unless pid.strip.empty?
    end

    desc "Restart the mongodb server"
    task :restart, :role => :app do
      pid = capture("ps -o pid,command ax | grep mongod | awk '!/awk/ && !/grep/ {print $1}'")
      mongodb.stop unless pid.strip.empty?
      mongodb.start
    end

  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
cap-recipes-0.3.39 lib/cap_recipes/tasks/mongodb/manage.rb
cap-recipes-0.3.38 lib/cap_recipes/tasks/mongodb/manage.rb
cap-recipes-0.3.37 lib/cap_recipes/tasks/mongodb/manage.rb