jnewland / san_juan

Capistrano Recipies for God

This URL has Read+Write access

san_juan / lib / san_juan.rb
bbe48355 » jnewland 2008-05-20 initial import 1 module SanJuan
2 @@roles = []
3
4 def roles
5 @@roles
6 end
7
8 def role(role, watches)
9 @@roles << role
10
11 namespace :god do
12
d1462c0c » jnewland 2008-05-20 fix meta tasks 13 unless @meta_tasks_defined
14 namespace :all do
15 desc "Describe the status of the running tasks on each server"
16 task :status, :roles => san_juan.roles do
17 san_juan.roles.each { |role| send(role, :status) }
18 end
19
20 desc "Start god"
21 task :start do
22 san_juan.roles.each { |role| send(role, :start) }
23 end
24
25 desc "Reloading God Config"
26 task :reload do
27 san_juan.roles.each { |role| send(role, :reload) }
28 end
29
30 desc "Start god interactively"
31 task :start_interactive do
32 san_juan.roles.each { |role| send(role, :start_interactive) }
33 end
34
35 desc "Quit god, but not the processes it's monitoring"
36 task :quit do
37 san_juan.roles.each { |role| send(role, :quit) }
38 end
39
40 desc "Terminate god and all monitored processes"
41 task :terminate do
42 san_juan.roles.each { |role| send(role, :terminate) }
43 end
44 end
45 end
bbe48355 » jnewland 2008-05-20 initial import 46 @meta_tasks_defined = true
47
48 namespace role do
49 desc "Start god"
50 task :start, :roles => role do
51 sudo "god -c #{san_juan.configuration_path(current_path, role)}"
52 end
53
54 desc "Start god interactively"
55 task :start_interactive, :roles => role do
56 sudo "god -c #{san_juan.configuration_path(current_path, role)} -D"
57 end
58
59 desc "Reload the god config file"
60 task :reload, :roles => role do
1a4aabce » jnewland 2008-06-23 fix reload task 61 sudo "god load #{san_juan.configuration_path(current_path, role)}"
bbe48355 » jnewland 2008-05-20 initial import 62 end
63
64 desc "Quit god, but not the processes it's monitoring"
65 task :quit, :roles => role do
66 sudo 'god quit'
67 end
68
69 desc "Terminate god and all monitored processes"
70 task :terminate, :roles => role do
71 sudo 'god terminate'
72 end
73
74 watches.each do |watch|
75 namespace watch do
76 %w(start restart stop unmonitor remove log).each do |command|
77 desc "#{command.capitalize} #{watch}"
78 task command, :roles => role do
79 sudo "god #{command} #{watch}"
80 end
81 end
82 end
83 end
84
85 end # end role namespace
86
87 end #end god namespace
88 end
89
90 def configuration_path(current_path, role)
91 fetch(:god_config_path, nil) || "#{current_path}/config/god/#{role}.god"
92 end
93
94 end
95 Capistrano.plugin :san_juan, SanJuan