jnewland-san_juan 0.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. data/README.textile +137 -0
  2. data/lib/san_juan.rb +95 -0
  3. metadata +71 -0
data/README.textile ADDED
@@ -0,0 +1,137 @@
1
+ h2. Description
2
+
3
+ Want "Capistrano":http://capify.org/ to talk to "God":http://god.rubyforge.org/? Find "San Juan":http://maps.google.com/maps?client=safari&ie=UTF8&oe=UTF-8&q=San+Juan+Capistrano,+CA,+USA&ll=33.495598,-117.665291&spn=0.020113,0.037851&t=h&z=15
4
+
5
+ h2. Requirements
6
+
7
+ * "God":http://god.rubyforge.org/
8
+ * "Capistrano":http://capify.org/
9
+
10
+ h2. Install
11
+
12
+ <pre>
13
+ <code>
14
+ git clone git://github.com/jnewland/san_juan.git
15
+ cd san_juan
16
+ gem build san_juan.gemspec
17
+ sudo gem install -l san_juan-*.gem
18
+ </code>
19
+ </pre>
20
+
21
+ h2. Usage
22
+
23
+ In your Capistrano deploy recipie:
24
+
25
+ <pre>
26
+ <code>
27
+ require 'san_juan'
28
+
29
+ role :app, 'foo.example.com'
30
+ role :web, 'bar.example.com'
31
+
32
+ san_juan.role :app, %w(mongrels memcached)
33
+ san_juan.role :web, %w(nginx)
34
+ </code>
35
+ </pre>
36
+
37
+ Now, check out @cap -T@:
38
+
39
+ <pre>
40
+ <code>
41
+ ...
42
+ cap god:all:quit # Quit god, but not the processes it's monito...
43
+ cap god:all:reload # Reloading God Config
44
+ cap god:all:start # Start god
45
+ cap god:all:start_interactive # Start god interactively
46
+ cap god:all:status # Describe the status of the running tasks on...
47
+ cap god:all:terminate # Terminate god and all monitored processes
48
+ cap god:app:memcached:log # Log memcached
49
+ cap god:app:memcached:remove # Remove memcached
50
+ cap god:app:memcached:restart # Restart memcached
51
+ cap god:app:memcached:start # Start memcached
52
+ cap god:app:memcached:stop # Stop memcached
53
+ cap god:app:memcached:unmonitor # Unmonitor memcached
54
+ cap god:app:mongrels:log # Log mongrels
55
+ cap god:app:mongrels:remove # Remove mongrels
56
+ cap god:app:mongrels:restart # Restart mongrels
57
+ cap god:app:mongrels:start # Start mongrels
58
+ cap god:app:mongrels:stop # Stop mongrels
59
+ cap god:app:mongrels:unmonitor # Unmonitor mongrels
60
+ cap god:app:quit # Quit god, but not the processes it's monito...
61
+ cap god:app:reload # Reload the god config file
62
+ cap god:app:start # Start god
63
+ cap god:app:start_interactive # Start god interactively
64
+ cap god:app:terminate # Terminate god and all monitored processes
65
+ cap god:web:nginx:log # Log nginx
66
+ cap god:web:nginx:remove # Remove nginx
67
+ cap god:web:nginx:restart # Restart nginx
68
+ cap god:web:nginx:start # Start nginx
69
+ cap god:web:nginx:stop # Stop nginx
70
+ cap god:web:nginx:unmonitor # Unmonitor nginx
71
+ cap god:web:quit # Quit god, but not the processes it's monito...
72
+ cap god:web:reload # Reload the god config file
73
+ cap god:web:start # Start god
74
+ cap god:web:start_interactive # Start god interactively
75
+ cap god:web:terminate # Terminate god and all monitored processes
76
+ ...
77
+ </pre>
78
+ </code>
79
+
80
+ To make capistrano start, stop, and restart your app using God, override the
81
+ @deploy:start@, @deploy:stop@, and @deploy:restart@ tasks:
82
+
83
+ <pre>
84
+ <code>
85
+ namespace :deploy do
86
+ desc "Use god to restart the app"
87
+ task :restart do
88
+ god.all.reload #ensures any changes to the god config are applied at deploy
89
+ god.app.mongrels.restart
90
+ # god.web.nginx.restart
91
+ # ...
92
+ end
93
+
94
+ desc "Use god to start the app"
95
+ task :start do
96
+ god.all.start
97
+ end
98
+
99
+ desc "Use god to stop the app"
100
+ task :stop do
101
+ god.all.terminate
102
+ end
103
+ end
104
+ </pre>
105
+ </code>
106
+
107
+ h2. Tweaks
108
+
109
+ A few of the tasks in the @god:all@ namespace require the path to your god
110
+ configuration file. This defaults to:
111
+
112
+ @"#{current_path}/config/god/#{role}.god"@
113
+
114
+ This can be changed by setting the @god_config_path@ capistrano variable:
115
+
116
+ <pre>
117
+ <code>
118
+ require 'san_juan'
119
+
120
+ set :god_config_path, "/path/to/config"
121
+
122
+ role :app, 'foo.example.com'
123
+ role :web, 'bar.example.com'
124
+
125
+ san_juan.role :app, %w(mongrels memcached)
126
+ san_juan.role :web, %w(nginx)
127
+
128
+ </code>
129
+ </pre>
130
+
131
+ h2. Author
132
+
133
+ "Jesse Newland":http://jnewland.com/
134
+
135
+ h2. License
136
+
137
+ "WTFPL":http://sam.zoy.org/wtfpl/
data/lib/san_juan.rb ADDED
@@ -0,0 +1,95 @@
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
+
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
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
61
+ sudo "god load #{san_juan.configuration_path(current_path, role)}"
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
metadata ADDED
@@ -0,0 +1,71 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: jnewland-san_juan
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.2
5
+ platform: ruby
6
+ authors:
7
+ - Jesse Newland
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2008-05-20 00:00:00 -07:00
13
+ default_executable:
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: god
17
+ version_requirement:
18
+ version_requirements: !ruby/object:Gem::Requirement
19
+ requirements:
20
+ - - ">="
21
+ - !ruby/object:Gem::Version
22
+ version: "0"
23
+ version:
24
+ - !ruby/object:Gem::Dependency
25
+ name: capistrano
26
+ version_requirement:
27
+ version_requirements: !ruby/object:Gem::Requirement
28
+ requirements:
29
+ - - ">="
30
+ - !ruby/object:Gem::Version
31
+ version: "0"
32
+ version:
33
+ description: Capistrano Recipies for God
34
+ email: jnewland@gmail.com
35
+ executables: []
36
+
37
+ extensions: []
38
+
39
+ extra_rdoc_files:
40
+ - README.textile
41
+ files:
42
+ - lib/san_juan.rb
43
+ - README.textile
44
+ has_rdoc: false
45
+ homepage: http://github.com/jnewland/san_juan
46
+ post_install_message:
47
+ rdoc_options: []
48
+
49
+ require_paths:
50
+ - lib
51
+ required_ruby_version: !ruby/object:Gem::Requirement
52
+ requirements:
53
+ - - ">="
54
+ - !ruby/object:Gem::Version
55
+ version: "0"
56
+ version:
57
+ required_rubygems_version: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: "0"
62
+ version:
63
+ requirements: []
64
+
65
+ rubyforge_project:
66
+ rubygems_version: 1.0.1
67
+ signing_key:
68
+ specification_version: 2
69
+ summary: Capistrano Recipies for God
70
+ test_files: []
71
+