forked from gabriel/capitate
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
69 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 %> |