Skip to content

Commit

Permalink
task arg dsl patch
Browse files Browse the repository at this point in the history
  • Loading branch information
gabriel committed May 14, 2008
1 parent 8e757e1 commit bf0b032
Show file tree
Hide file tree
Showing 3 changed files with 69 additions and 0 deletions.
34 changes: 34 additions & 0 deletions lib/capitate/cap_ext/namespace.rb
@@ -0,0 +1,34 @@
module Capitate

module CapExt

module Namespace

def self.included(base) #:nodoc:
unless base.method_defined?(:task_without_capitate)
base.send :alias_method, :task_without_capitate, :task
base.send :alias_method, :task, :task_with_capitate
end
end

def task_arg(name, desc, options = {})
@next_task_arguments ||= []
@next_task_arguments << options.merge({ :name => name, :desc => desc })
end

def task_with_capitate(name, options={}, &block)
task_without_capitate(name, options) do
find_task(name).setup_defaults
block.call
end
task_def = find_task(name)
task_def.arguments = @next_task_arguments
@next_task_arguments = nil
task_def
end

end

end

end
22 changes: 22 additions & 0 deletions lib/capitate/cap_ext/task_definition.rb
@@ -0,0 +1,22 @@
module Capitate

module CapExt

module TaskDefinition

attr_accessor :arguments

def setup_defaults
return if arguments.blank?

arguments.each do |arg|
namespace.fetch_or_default(arg[:name], arg[:default]) if arg.has_key?(:default)
namespace.fetch_or_set(arg[:name], arg[:set]) if arg.has_key?(:set)
end
end

end

end

end
13 changes: 13 additions & 0 deletions lib/templates/merb/merb-no-http.monitrc.erb
@@ -0,0 +1,13 @@
<% processes.each do |process| %>

check process <%= merb_application %>_<%= process[:port] %> with pidfile <%= process[:pid_path] %>
group <%= merb_application %>
start program = "<%= process[:start] %>"
stop program = "<%= process[:stop] %>"
if totalmem > 100 Mb then restart
if cpu is greater than 60% for 2 cycles then alert
if cpu > 80% for 5 cycles then restart
if loadavg(5min) greater than 10 for 8 cycles then restart
if 3 restarts within 5 cycles then timeout

<% end %>

0 comments on commit bf0b032

Please sign in to comment.