32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
|
# File 'lib/gap/tasks.rb', line 32
def define_config_tasks value
return unless value
value.each do |attr,val|
case attr
when "role"
val.each { |attr, val| role attr.to_sym, val } if val
when "set"
val.each { |attr, val| set attr, val } if val
else
val.each do |a, v|
case a
when "role"
v.each { |attr, val| role attr.to_sym, val } if v
when "set"
v.each { |attr, val| set attr, val } if v
when "task"
if fetch :god
task(attr) do
namespace :god do
task(:config) do
god_config_path = File.join( deploy_to, "config/god_#{application}_#{attr}.rb")
tmpl_path = File.expand_path 'tmpl.erb', File.dirname(__FILE__)
god_config = Gap::GodErb.new(tmpl_path,application, attr, v.merge({"pid_file" => pid_file}))
upload( god_config.render, god_config_path, :via => :scp)
sudo "rvm-shell '#{rvm_god_string}' -c 'god load #{god_config_path}'"
end
end
v.each do |name, command|
if ["start","stop","restart"].include?(name)
task(name) do
sudo "rvm-shell '#{rvm_god_string}' -c 'god #{name} #{attr}_#{application}'"
end
else
task(name) do
sudo_run command
end
end
end
end
else
task(attr) do
v.each do |name, command|
task(name) { sudo_run command }
end
end
end
else
end
end
end
end
end
|