Skip to content

Commit

Permalink
experimental rake tasks to control rabbitmq.
Browse files Browse the repository at this point in the history
note that it requires that dtach is installed.

Signed-off-by: ezmobius <ez@engineyard.com>
  • Loading branch information
careo authored and ezmobius committed Jan 23, 2009
1 parent 4491f4d commit 9d5260d
Show file tree
Hide file tree
Showing 2 changed files with 75 additions and 0 deletions.
2 changes: 2 additions & 0 deletions Rakefile
Expand Up @@ -9,6 +9,8 @@ EMAIL = "ezra@engineyard.com"
HOMEPAGE = "http://github.com/ezmobius/nanite"
SUMMARY = "self assembling fabric of ruby daemons"

Dir.glob('tasks/*.rake').each { |r| Rake.application.add_import r }

spec = Gem::Specification.new do |s|
s.name = GEM
s.version = ::VER
Expand Down
73 changes: 73 additions & 0 deletions tasks/rabbitmq.rake
@@ -0,0 +1,73 @@
# Inspired by rabbitmq.rake the Redbox project at http://github.com/rick/redbox/tree/master

class RabbitMQ

def self.basedir
basedir = File.expand_path(File.dirname(__FILE__) + "/../") # ick
end

def self.rabbitdir
"#{basedir}/vendor/rabbitmq-server-1.5.0"
end

def self.dtach_socket
"#{basedir}/tmp/rabbitmq.dtach"
end

# Just check for existance of dtach socket
def self.running?
File.exists? dtach_socket
end

def self.setup_environment
ENV['MNESIA_BASE'] ||= "#{basedir}/db/mnesia"
ENV['LOG_BASE'] ||= "#{basedir}.log"
ENV['RABBITMQ_NODE_ONLY'] ||= "0" # to get an erlang shell
end

def self.start
setup_environment
exec "dtach -n #{dtach_socket} #{rabbitdir}/scripts/rabbitmq-server"
end

def self.attach
exec "dtach -a #{dtach_socket}"
end

def self.stop
system "#{rabbitdir}/scripts/rabbitmqctl stop"
end

end

namespace :rabbitmq do

desc "Start RabbitMQ"
task :start do
RabbitMQ.start
end

desc "stop"
task :stop do
RabbitMQ.stop
end

desc "Attach to RabbitMQ dtach socket"
task :attach do
RabbitMQ.attach
end

namespace :package do

desc "Download package"
task :download do
Dir.chdir("vendor") do
system "wget http://www.rabbitmq.com/releases/rabbitmq-server/v1.5.0/rabbitmq-server-1.5.0.tar.gz"
end
end

end


end

0 comments on commit 9d5260d

Please sign in to comment.