andrey_san_juan 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. data/README.textile +136 -0
  2. data/lib/san_juan.rb +101 -0
  3. metadata +81 -0
@@ -0,0 +1,136 @@
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
+ gem install jnewland-san_juan
15
+ OR
16
+ gem install jnewland-san_juan -s http://gems.github.com
17
+ </code>
18
+ </pre>
19
+
20
+ h2. Usage
21
+
22
+ In your Capistrano deploy recipie:
23
+
24
+ <pre>
25
+ <code>
26
+ require 'san_juan'
27
+
28
+ role :app, 'foo.example.com'
29
+ role :web, 'bar.example.com'
30
+
31
+ san_juan.role :app, %w(mongrels memcached)
32
+ san_juan.role :web, %w(nginx)
33
+ </code>
34
+ </pre>
35
+
36
+ Now, check out @cap -T@:
37
+
38
+ <pre>
39
+ <code>
40
+ ...
41
+ cap god:all:quit # Quit god, but not the proce...
42
+ cap god:all:reload # Reloading God Config
43
+ cap god:all:start # Start god
44
+ cap god:all:start_interactive # Start god interactively
45
+ cap god:all:status # Describe the status of the ...
46
+ cap god:all:terminate # Terminate god and all monit...
47
+ cap god:app:mongrels:log # Log mongrels
48
+ cap god:app:mongrels:remove # Remove mongrels
49
+ cap god:app:mongrels:restart # Restart mongrels
50
+ cap god:app:mongrels:start # Start mongrels
51
+ cap god:app:mongrels:stop # Stop mongrels
52
+ cap god:app:mongrels:unmonitor # Unmonitor mongrels
53
+ cap god:app:memcached:log # Log memcached
54
+ cap god:app:memcached:remove # Remove memcached
55
+ cap god:app:memcached:restart # Restart memcached
56
+ cap god:app:memcached:start # Start memcached
57
+ cap god:app:memcached:stop # Stop memcached
58
+ cap god:app:memcached:unmonitor # Unmonitor memcached
59
+ cap god:app:quit # Quit god, but not the proce...
60
+ cap god:app:reload # Reload the god config file
61
+ cap god:app:start # Start god
62
+ cap god:app:start_interactive # Start god interactively
63
+ cap god:app:terminate # Terminate god and all monit...
64
+ cap god:web:nginx:log # Log nginx
65
+ cap god:web:nginx:remove # Remove nginx
66
+ cap god:web:nginx:restart # Restart nginx
67
+ cap god:web:nginx:start # Start nginx
68
+ cap god:web:nginx:stop # Stop nginx
69
+ cap god:web:nginx:unmonitor # Unmonitor nginx
70
+ cap god:web:quit # Quit god, but not the proce...
71
+ cap god:web:reload # Reload the god config file
72
+ cap god:web:start # Start god
73
+ cap god:web:start_interactive # Start god interactively
74
+ cap god:web:terminate # Terminate god and all monit...
75
+ ...
76
+ </pre>
77
+ </code>
78
+
79
+ To make capistrano start, stop, and restart your app using God, override the
80
+ @deploy:start@, @deploy:stop@, and @deploy:restart@ tasks:
81
+
82
+ <pre>
83
+ <code>
84
+ namespace :deploy do
85
+ desc "Use god to restart the app"
86
+ task :restart do
87
+ god.all.reload #ensures any changes to the god config are applied at deploy
88
+ god.app.mongrels.restart
89
+ # god.web.nginx.restart
90
+ # ...
91
+ end
92
+
93
+ desc "Use god to start the app"
94
+ task :start do
95
+ god.all.start
96
+ end
97
+
98
+ desc "Use god to stop the app"
99
+ task :stop do
100
+ god.all.terminate
101
+ end
102
+ end
103
+ </pre>
104
+ </code>
105
+
106
+ h2. Tweaks
107
+
108
+ A few of the tasks in the @god:all@ namespace require the path to your god
109
+ configuration file. This defaults to:
110
+
111
+ @"#{current_path}/config/god/#{role}.god"@
112
+
113
+ This can be changed by setting the @god_config_path@ capistrano variable:
114
+
115
+ <pre>
116
+ <code>
117
+ require 'san_juan'
118
+
119
+ set :god_config_path, "/path/to/config"
120
+
121
+ role :app, 'foo.example.com'
122
+ role :web, 'bar.example.com'
123
+
124
+ san_juan.role :app, %w(mongrels memcached)
125
+ san_juan.role :web, %w(nginx)
126
+
127
+ </code>
128
+ </pre>
129
+
130
+ h2. Author
131
+
132
+ "Jesse Newland":http://jnewland.com/
133
+
134
+ h2. License
135
+
136
+ "WTFPL":http://sam.zoy.org/wtfpl/
@@ -0,0 +1,101 @@
1
+ module SanJuan
2
+ @@roles = []
3
+
4
+ def roles
5
+ @@roles
6
+ end
7
+
8
+ def role(role, watches)
9
+ via = fetch(:run_method, :sudo)
10
+ @@roles << role
11
+
12
+ namespace :god do
13
+
14
+ unless @meta_tasks_defined
15
+ namespace :all do
16
+ desc "Describe the status of the running tasks on each server"
17
+ task :status do
18
+ san_juan.roles.each { |role| send(role).send(:status) }
19
+ end
20
+
21
+ desc "Start god"
22
+ task :start do
23
+ san_juan.roles.each { |role| send(role).send(:start) }
24
+ end
25
+
26
+ desc "Reloading God Config"
27
+ task :reload do
28
+ san_juan.roles.each { |role| send(role).send(:reload) }
29
+ end
30
+
31
+ desc "Start god interactively"
32
+ task :start_interactive do
33
+ san_juan.roles.each { |role| send(role).send(:start_interactive) }
34
+ end
35
+
36
+ desc "Quit god, but not the processes it's monitoring"
37
+ task :quit do
38
+ san_juan.roles.each { |role| send(role).send(:quit) }
39
+ end
40
+
41
+ desc "Terminate god and all monitored processes"
42
+ task :terminate do
43
+ san_juan.roles.each { |role| send(role).send(:terminate) }
44
+ end
45
+ end
46
+ end
47
+ @meta_tasks_defined = true
48
+
49
+ namespace role do
50
+ desc "Start god"
51
+ task :start, :roles => role do
52
+ invoke_command "god -c #{san_juan.configuration_path(current_path, role)}", :via => via
53
+ end
54
+
55
+ desc "Start god interactively"
56
+ task :start_interactive, :roles => role do
57
+ invoke_command "god -c #{san_juan.configuration_path(current_path, role)} -D", :via => via
58
+ end
59
+
60
+ desc "Reload the god config file"
61
+ task :reload, :roles => role do
62
+ invoke_command "god load #{san_juan.configuration_path(current_path, role)}", :via => via
63
+ end
64
+
65
+ desc "Quit god, but not the processes it's monitoring"
66
+ task :quit, :roles => role do
67
+ invoke_command 'god quit', :via => via
68
+ end
69
+
70
+ desc "Terminate god and all monitored processes"
71
+ task :terminate, :roles => role do
72
+ invoke_command 'god terminate', :via => via
73
+ end
74
+
75
+ desc "Describe the status of the running tasks"
76
+ task :status, :roles => role do
77
+ invoke_command 'god status', :via => via
78
+ end
79
+
80
+ watches.each do |watch|
81
+ namespace watch do
82
+ %w(start restart stop unmonitor remove log).each do |command|
83
+ desc "#{command.capitalize} #{watch}"
84
+ task command, :roles => role do
85
+ invoke_command "god #{command} #{watch}", :via => via
86
+ end
87
+ end
88
+ end
89
+ end
90
+
91
+ end # end role namespace
92
+
93
+ end #end god namespace
94
+ end
95
+
96
+ def configuration_path(current_path, role)
97
+ fetch(:god_config_path, nil) || "#{current_path}/config/god/#{role}.god"
98
+ end
99
+
100
+ end
101
+ Capistrano.plugin :san_juan, SanJuan
metadata ADDED
@@ -0,0 +1,81 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: andrey_san_juan
3
+ version: !ruby/object:Gem::Version
4
+ hash: 21
5
+ prerelease:
6
+ segments:
7
+ - 0
8
+ - 0
9
+ - 5
10
+ version: 0.0.5
11
+ platform: ruby
12
+ authors:
13
+ - Jesse Newland
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2008-05-20 00:00:00 +04:00
19
+ default_executable:
20
+ dependencies:
21
+ - !ruby/object:Gem::Dependency
22
+ name: capistrano
23
+ prerelease: false
24
+ requirement: &id001 !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ">="
28
+ - !ruby/object:Gem::Version
29
+ hash: 3
30
+ segments:
31
+ - 0
32
+ version: "0"
33
+ type: :runtime
34
+ version_requirements: *id001
35
+ description: Capistrano Recipies for God
36
+ email: jnewland@gmail.com
37
+ executables: []
38
+
39
+ extensions: []
40
+
41
+ extra_rdoc_files:
42
+ - README.textile
43
+ files:
44
+ - lib/san_juan.rb
45
+ - README.textile
46
+ has_rdoc: true
47
+ homepage: http://github.com/AndreyChernyh/san_juan
48
+ licenses: []
49
+
50
+ post_install_message:
51
+ rdoc_options: []
52
+
53
+ require_paths:
54
+ - lib
55
+ required_ruby_version: !ruby/object:Gem::Requirement
56
+ none: false
57
+ requirements:
58
+ - - ">="
59
+ - !ruby/object:Gem::Version
60
+ hash: 3
61
+ segments:
62
+ - 0
63
+ version: "0"
64
+ required_rubygems_version: !ruby/object:Gem::Requirement
65
+ none: false
66
+ requirements:
67
+ - - ">="
68
+ - !ruby/object:Gem::Version
69
+ hash: 3
70
+ segments:
71
+ - 0
72
+ version: "0"
73
+ requirements: []
74
+
75
+ rubyforge_project:
76
+ rubygems_version: 1.5.2
77
+ signing_key:
78
+ specification_version: 2
79
+ summary: Capistrano Recipies for God
80
+ test_files: []
81
+