cap-recipes 0.3.18

Sign up to get free protection for your applications and to get access to all the features.
Files changed (46) hide show
  1. data/.gitignore +3 -0
  2. data/LICENSE +20 -0
  3. data/README.textile +357 -0
  4. data/Rakefile +45 -0
  5. data/VERSION.yml +4 -0
  6. data/cap-recipes.gemspec +87 -0
  7. data/examples/advanced/deploy.rb +39 -0
  8. data/examples/advanced/deploy/experimental.rb +14 -0
  9. data/examples/advanced/deploy/production.rb +20 -0
  10. data/examples/simple/deploy.rb +36 -0
  11. data/lib/cap_recipes.rb +1 -0
  12. data/lib/cap_recipes/tasks/apache.rb +1 -0
  13. data/lib/cap_recipes/tasks/apache/install.rb +12 -0
  14. data/lib/cap_recipes/tasks/apache/manage.rb +26 -0
  15. data/lib/cap_recipes/tasks/aptitude.rb +1 -0
  16. data/lib/cap_recipes/tasks/aptitude/manage.rb +34 -0
  17. data/lib/cap_recipes/tasks/backgroundrb.rb +1 -0
  18. data/lib/cap_recipes/tasks/backgroundrb/hooks.rb +5 -0
  19. data/lib/cap_recipes/tasks/backgroundrb/manage.rb +64 -0
  20. data/lib/cap_recipes/tasks/delayed_job.rb +1 -0
  21. data/lib/cap_recipes/tasks/delayed_job/hooks.rb +5 -0
  22. data/lib/cap_recipes/tasks/delayed_job/manage.rb +32 -0
  23. data/lib/cap_recipes/tasks/juggernaut.rb +1 -0
  24. data/lib/cap_recipes/tasks/juggernaut/hooks.rb +4 -0
  25. data/lib/cap_recipes/tasks/juggernaut/manage.rb +54 -0
  26. data/lib/cap_recipes/tasks/memcache.rb +1 -0
  27. data/lib/cap_recipes/tasks/memcache/hooks.rb +5 -0
  28. data/lib/cap_recipes/tasks/memcache/install.rb +13 -0
  29. data/lib/cap_recipes/tasks/memcache/manage.rb +35 -0
  30. data/lib/cap_recipes/tasks/passenger.rb +1 -0
  31. data/lib/cap_recipes/tasks/passenger/install.rb +62 -0
  32. data/lib/cap_recipes/tasks/passenger/manage.rb +24 -0
  33. data/lib/cap_recipes/tasks/rails.rb +1 -0
  34. data/lib/cap_recipes/tasks/rails/hooks.rb +8 -0
  35. data/lib/cap_recipes/tasks/rails/manage.rb +53 -0
  36. data/lib/cap_recipes/tasks/rubygems.rb +1 -0
  37. data/lib/cap_recipes/tasks/rubygems/manage.rb +43 -0
  38. data/lib/cap_recipes/tasks/utilities.rb +114 -0
  39. data/lib/cap_recipes/tasks/whenever.rb +1 -0
  40. data/lib/cap_recipes/tasks/whenever/hooks.rb +5 -0
  41. data/lib/cap_recipes/tasks/whenever/manage.rb +10 -0
  42. data/spec/cap/all/Capfile +2 -0
  43. data/spec/cap/helper.rb +2 -0
  44. data/spec/cap_recipes_spec.rb +13 -0
  45. data/spec/spec_helper.rb +16 -0
  46. metadata +106 -0
data/.gitignore ADDED
@@ -0,0 +1,3 @@
1
+ .DS_Store
2
+ pkg*
3
+ .svn
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2008 Nathan Esquenazi
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.textile ADDED
@@ -0,0 +1,357 @@
1
+ h1. cap-recipes
2
+
3
+ A collection of useful capistrano recipes I have been using in production on a number of sites.
4
+
5
+ This gem is best suited for ruby (and rails) projects which deploy using Apache and Phusion Passenger.
6
+ Feel free to contribute to this collection and make it even better!
7
+
8
+ The overall vision for this project being to collect a number of classic, generic recipes which can
9
+ be used by the community.
10
+
11
+ Currently included:
12
+
13
+ * Apache Server
14
+ * Rubygems Package Management
15
+ * Phusion Passenger (Setup and Deployment)
16
+ * Memcache Process (Setup and Deployment)
17
+ * Juggernaut Daemon
18
+ * Backgroundrb Server
19
+ * DelayedJob Worker
20
+ * Whenever Cron Scheduling
21
+ * Aptitude Package Management
22
+
23
+ h2. INSTALLATION
24
+
25
+ sudo gem install nesquena-cap-recipes -s http://gems.github.com/
26
+
27
+ Include into your deploy.rb configuration file for Capistrano:
28
+
29
+ <pre>
30
+ <code>
31
+ # use the complete deployment process (NOT RECOMMENDED)
32
+ require 'cap_recipes'
33
+
34
+ # RECOMMENDED
35
+ # require necessary recipes according to your needs
36
+ # (use hooks which tie all the recipes into the deployment process,
37
+ # tasks for managing and tasks for installing):
38
+ require 'cap_recipes/tasks/memcache'
39
+ require 'cap_recipes/tasks/passenger'
40
+ # or rails, apache, rubygems, delayed_job, juggernaut, backgroundrb, aptitude, whenever
41
+
42
+ # OR
43
+ # only use managing tasks:
44
+ require 'cap_recipes/tasks/memcache/manage'
45
+
46
+ # OR
47
+ #only use install tasks:
48
+ require 'cap_recipes/tasks/memcache/install'
49
+ </code>
50
+ </pre>
51
+
52
+ h2. USAGE
53
+
54
+ h3. Apache
55
+
56
+ These recipes manage the apache web server
57
+
58
+ h4. Configuration
59
+
60
+ * apache_init_path - the path to the init.d apache file [default: '/etc/init.d/apache2']
61
+
62
+ h4. Tasks
63
+
64
+ h5. manage.rb
65
+
66
+ apache
67
+ :stop
68
+ :start
69
+ :restart
70
+
71
+ h5. install.rb
72
+
73
+ apache
74
+ :install
75
+
76
+ h3. Rubygems
77
+
78
+ h4. Configuration
79
+
80
+ * rubygem_paths - a path or array of paths to your gem binaries [default '/usr/bin/gem' ]
81
+
82
+ h4. Tasks
83
+
84
+ h5. manage.rb
85
+
86
+ rubygems
87
+ :full_update
88
+ :upgrade
89
+ :update
90
+ :cleanup
91
+ :install
92
+ :uninstall
93
+
94
+ h3. Passenger
95
+
96
+ These recipes manage the passenger module for apache
97
+
98
+ h4. Configuration
99
+
100
+ * base_ruby_path - the base path to the ruby installation [default: '/usr']
101
+ * local_ping_path - the localhost path to ping to start passenger [default: "http://localhost"]
102
+
103
+ The following files and folders are expected to exist:
104
+ * "#{base_ruby_path}/lib/ruby"
105
+ * "#{base_ruby_path}/bin/ruby"
106
+ * "#{base_ruby_path}/bin/gem"
107
+
108
+ h4. Tasks
109
+
110
+ h5. manage.rb
111
+
112
+ deploy
113
+ :start
114
+ :stop
115
+ :restart
116
+ :with_migrations
117
+
118
+ h5. install.rb
119
+
120
+ passenger
121
+ :install
122
+
123
+ h3. Aptitude
124
+
125
+ h4. Tasks
126
+
127
+ h5. manage.rb
128
+
129
+ aptitude
130
+ :install
131
+ :remove
132
+ :updates
133
+
134
+ h3. Rails
135
+
136
+ These recipes support rails-specific functionality
137
+
138
+ h4. Tasks
139
+
140
+ h5. manage.rb
141
+
142
+ rails
143
+ :symlink_db_config
144
+ :repair_permissions
145
+ :tail - tail production log
146
+ :ping - ping the server to start it
147
+ sweep
148
+ :cache
149
+ :log
150
+
151
+ h5. hooks.rb
152
+
153
+ after "deploy:update_code", "rails:symlink_db_config" # copy database.yml file to release path
154
+ after "deploy:update_code", "rails:sweep:cache" # clear cache after updating code
155
+ after "deploy:restart" , "rails:repair_permissions" # fix the permissions to work properly
156
+ after "deploy:restart" , "rails:ping" # ping passenger to start the rails instance
157
+
158
+ h3. DelayedJob
159
+
160
+ These recipes are for tobi's delayed_job plugin for background job queue processing
161
+
162
+ h4. Configuration
163
+
164
+ * delayed_script_path - the path to the delayed job script [default: 'script/delayed_job']
165
+ * delayed_job_env - the rails environment [default: 'production']
166
+
167
+ h4. Tasks
168
+
169
+ h5. manage.rb
170
+
171
+ delayed_job
172
+ :stop
173
+ :start
174
+ :restart
175
+
176
+ h5. hooks.rb
177
+
178
+ after "deploy:start", "delayed_job:start"
179
+ after "deploy:stop", "delayed_job:stop"
180
+ after "deploy:restart", "delayed_job:restart"
181
+
182
+ h3. Backgroundrb
183
+
184
+ These recipes are for backgroundrb job queue processing
185
+
186
+ h4. Configuration
187
+
188
+ * backgroundrb_log - the path to the backgroundrb log file
189
+ * backgroundrb_host - the background host machine ip [default: 'localhost']
190
+ * backgroundrb_env - the rails environment [default: 'production']
191
+
192
+ h4. Tasks
193
+
194
+ h5. manage.rb
195
+
196
+ backgroundrb
197
+ :stop
198
+ :start
199
+ :restart
200
+ :symlink_config
201
+ :tail
202
+
203
+ h5. hooks.rb
204
+
205
+ after "deploy:update_code" , "backgroundrb:symlink_config" # copy backgroundrb config to release
206
+ after "deploy:restart" , "backgroundrb:restart" # restart backgroundrb daemon
207
+ after "backgroundrb:restart" , "backgroundrb:repair_permissions" # restart backgroundrb damon
208
+
209
+ h3. Juggernaut
210
+
211
+ These recipes are for managing the juggernaut push server
212
+
213
+ h4. Configuration
214
+
215
+ * juggernaut_config - path to juggernaut config file [default: "#{current_path}/config/juggernaut.yml"]
216
+ * juggernaut_pid - path to juggernaut pid file [default: "#{current_path}/tmp/pids/juggernaut.pid"]
217
+ * juggernaut_log - path to juggernaut log file [default: "#{current_path}/log/juggernaut.log"]
218
+
219
+ h4. Tasks
220
+
221
+ h5. manage.rb
222
+
223
+ juggernaut
224
+ :start
225
+ :stop
226
+ :restart
227
+ :symlink_config
228
+ :tail
229
+
230
+ h5. hooks.rb
231
+
232
+ after "deploy:update_code", "juggernaut:symlink_config" # copy juggernaut.yml to release
233
+ after "deploy:restart" , "juggernaut:restart" # restart juggernaut daemon
234
+
235
+ h3. Memcache
236
+
237
+ These recipes are for managing the memcached caching mechanism
238
+
239
+ h4. Configuration
240
+
241
+ * memcache_init_path - path to memcache config file [default: "/etc/init.d/memcache"]
242
+ * memcache_size - the total size of memory to use [default: 64]
243
+ * memcache_port - the port to start memcache [default: '11211']
244
+ * memcache_host - the host for memcache [default: '127.0.0.1']
245
+ * memcache_user - the user to run memcache [default: 'nobody']
246
+
247
+ h4. Tasks
248
+
249
+ h5. manage.rb
250
+
251
+ memcache
252
+ :start
253
+ :stop
254
+ :restart
255
+
256
+ h5. install.rb
257
+
258
+ memcache
259
+ :install
260
+
261
+ h5. hooks
262
+
263
+ after "deploy:restart", "memcache:restart" # clear cache after updating code
264
+
265
+ h3. Whenever
266
+
267
+ These recipes are for managing whenever cron job scheduling
268
+
269
+ h4. Configuration
270
+
271
+ * None necessary yet
272
+
273
+ h4. Tasks
274
+
275
+ h5. manage.rb
276
+
277
+ whenever
278
+ :update_crontab
279
+
280
+ h5. hooks
281
+
282
+ after "deploy:symlink", "whenever:update_crontab"
283
+
284
+ h2. EXAMPLE
285
+
286
+ Here is a sample deploy.rb file using cap_recipes:
287
+
288
+ <pre>
289
+ <code>
290
+ # =============================================================================
291
+ # GENERAL SETTINGS
292
+ # =============================================================================
293
+
294
+ set :application, "app_name"
295
+ set :deploy_to, "/var/apps/#{application}"
296
+ set :scm, :git
297
+ set :repository, "git@repos.site.com:/home/git/repos.git"
298
+
299
+ # =============================================================================
300
+ # CAP RECIPES
301
+ # =============================================================================
302
+
303
+ # Note this happens after the general settings have been defined
304
+ require 'rubygems'
305
+
306
+ # PASSENGER
307
+ require 'cap_recipes/tasks/passenger'
308
+ set :base_ruby_path, '/opt/ruby-enterprise' # defaults to "/usr"
309
+ set :apache_init_path, '/etc/init.d/apache2' # defaults to "/etc/init.d/apache2"
310
+
311
+ # BACKGROUNDRB
312
+ require 'cap_recipes/tasks/backgroundrb'
313
+ set :backgroundrb_log, "/var/log/backgroundrb.log" # defaults to "#{release_path}/log/backgroundrb.log"
314
+ set :backgroundrb_host, "worker.site.com" # defaults to localhost
315
+ set :backgroundrb_env, "staging" # defaults to production
316
+
317
+ # DELAYED_JOB
318
+ require 'cap_recipes/tasks/delayed_job'
319
+ set :delayed_script_path, 'script/djworker' # defaults to 'script/delayed_job'
320
+ set :delayed_job_env, 'staging' # defaults to production
321
+
322
+ # JUGGERNAUT
323
+ require 'cap_recipes/tasks/juggernaut'
324
+ set :juggernaut_config, "/some/path/juggernaut.yml" # defaults to "#{current_path}/config/juggernaut.yml"
325
+ set :juggernaut_pid, "/some/path/juggernaut.pid" # defaults to "#{current_path}/tmp/pids/juggernaut.pid"
326
+ set :juggernaut_log, "/var/log/juggernaut.log" # defaults to #{release_path}/log/juggernaut.log
327
+
328
+ # MEMCACHE
329
+ require 'cap_recipes/tasks/memcache'
330
+ set :memcache_init_path, "/etc/init.d/memcache" # defaults to "/etc/init.d/memcache"
331
+ </code>
332
+ </pre>
333
+
334
+ h2. LICENSE:
335
+
336
+ (The MIT License)
337
+
338
+ Copyright (c) 2008 Nathan Esquenazi
339
+
340
+ Permission is hereby granted, free of charge, to any person obtaining
341
+ a copy of this software and associated documentation files (the
342
+ 'Software'), to deal in the Software without restriction, including
343
+ without limitation the rights to use, copy, modify, merge, publish,
344
+ distribute, sublicense, and/or sell copies of the Software, and to
345
+ permit persons to whom the Software is furnished to do so, subject to
346
+ the following conditions:
347
+
348
+ The above copyright notice and this permission notice shall be
349
+ included in all copies or substantial portions of the Software.
350
+
351
+ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
352
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
353
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
354
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
355
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
356
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
357
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/Rakefile ADDED
@@ -0,0 +1,45 @@
1
+ # rake version:bump:patch && rake release && rake build && rake install && sudo gem cleanup
2
+ require 'rake'
3
+ require 'rake/testtask'
4
+ require 'rake/rdoctask'
5
+
6
+ begin
7
+ require 'jeweler'
8
+ Jeweler::Tasks.new do |s|
9
+ s.name = "cap-recipes"
10
+ s.summary = %Q{Battle-tested capistrano recipes for passenger, delayed_job, and more}
11
+ s.email = "nesquena@gmail.com"
12
+ s.homepage = "http://github.com/nesquena/cap-recipes"
13
+ s.description = "Battle-tested capistrano recipes for debian, passenger, apache, delayed_job, juggernaut, rubygems, backgroundrb, rails and more"
14
+ s.authors = ["Nathan Esquenazi"]
15
+ end
16
+ rescue LoadError
17
+ puts "Jeweler not available. Install it with: sudo gem install technicalpickles-jeweler -s http://gems.github.com"
18
+ end
19
+
20
+ Rake::RDocTask.new do |rdoc|
21
+ rdoc.rdoc_dir = 'rdoc'
22
+ rdoc.title = 'cap-recipes'
23
+ rdoc.options << '--line-numbers' << '--inline-source'
24
+ rdoc.rdoc_files.include('README*')
25
+ rdoc.rdoc_files.include('lib/**/*.rb')
26
+ end
27
+
28
+ begin
29
+ require 'rcov/rcovtask'
30
+ Rcov::RcovTask.new do |t|
31
+ t.libs << 'test'
32
+ t.test_files = FileList['test/**/*_test.rb']
33
+ t.verbose = true
34
+ end
35
+ rescue LoadError
36
+ end
37
+
38
+ desc "Run all specs in spec directory"
39
+ task :spec do |t|
40
+ options = "--colour --format progress --loadby --reverse"
41
+ files = FileList['spec/**/*_spec.rb']
42
+ system("spec #{options} #{files}")
43
+ end
44
+
45
+ task :default => :spec
data/VERSION.yml ADDED
@@ -0,0 +1,4 @@
1
+ ---
2
+ :major: 0
3
+ :minor: 3
4
+ :patch: 18
@@ -0,0 +1,87 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ Gem::Specification.new do |s|
4
+ s.name = %q{cap-recipes}
5
+ s.version = "0.3.18"
6
+
7
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
8
+ s.authors = ["Nathan Esquenazi"]
9
+ s.date = %q{2009-06-15}
10
+ s.description = %q{Battle-tested capistrano recipes for debian, passenger, apache, delayed_job, juggernaut, rubygems, backgroundrb, rails and more}
11
+ s.email = %q{nesquena@gmail.com}
12
+ s.extra_rdoc_files = [
13
+ "LICENSE",
14
+ "README.textile"
15
+ ]
16
+ s.files = [
17
+ ".gitignore",
18
+ "LICENSE",
19
+ "README.textile",
20
+ "Rakefile",
21
+ "VERSION.yml",
22
+ "cap-recipes.gemspec",
23
+ "examples/advanced/deploy.rb",
24
+ "examples/advanced/deploy/experimental.rb",
25
+ "examples/advanced/deploy/production.rb",
26
+ "examples/simple/deploy.rb",
27
+ "lib/cap_recipes.rb",
28
+ "lib/cap_recipes/tasks/apache.rb",
29
+ "lib/cap_recipes/tasks/apache/install.rb",
30
+ "lib/cap_recipes/tasks/apache/manage.rb",
31
+ "lib/cap_recipes/tasks/aptitude.rb",
32
+ "lib/cap_recipes/tasks/aptitude/manage.rb",
33
+ "lib/cap_recipes/tasks/backgroundrb.rb",
34
+ "lib/cap_recipes/tasks/backgroundrb/hooks.rb",
35
+ "lib/cap_recipes/tasks/backgroundrb/manage.rb",
36
+ "lib/cap_recipes/tasks/delayed_job.rb",
37
+ "lib/cap_recipes/tasks/delayed_job/hooks.rb",
38
+ "lib/cap_recipes/tasks/delayed_job/manage.rb",
39
+ "lib/cap_recipes/tasks/juggernaut.rb",
40
+ "lib/cap_recipes/tasks/juggernaut/hooks.rb",
41
+ "lib/cap_recipes/tasks/juggernaut/manage.rb",
42
+ "lib/cap_recipes/tasks/memcache.rb",
43
+ "lib/cap_recipes/tasks/memcache/hooks.rb",
44
+ "lib/cap_recipes/tasks/memcache/install.rb",
45
+ "lib/cap_recipes/tasks/memcache/manage.rb",
46
+ "lib/cap_recipes/tasks/passenger.rb",
47
+ "lib/cap_recipes/tasks/passenger/install.rb",
48
+ "lib/cap_recipes/tasks/passenger/manage.rb",
49
+ "lib/cap_recipes/tasks/rails.rb",
50
+ "lib/cap_recipes/tasks/rails/hooks.rb",
51
+ "lib/cap_recipes/tasks/rails/manage.rb",
52
+ "lib/cap_recipes/tasks/rubygems.rb",
53
+ "lib/cap_recipes/tasks/rubygems/manage.rb",
54
+ "lib/cap_recipes/tasks/utilities.rb",
55
+ "lib/cap_recipes/tasks/whenever.rb",
56
+ "lib/cap_recipes/tasks/whenever/hooks.rb",
57
+ "lib/cap_recipes/tasks/whenever/manage.rb",
58
+ "spec/cap/all/Capfile",
59
+ "spec/cap/helper.rb",
60
+ "spec/cap_recipes_spec.rb",
61
+ "spec/spec_helper.rb"
62
+ ]
63
+ s.homepage = %q{http://github.com/nesquena/cap-recipes}
64
+ s.rdoc_options = ["--charset=UTF-8"]
65
+ s.require_paths = ["lib"]
66
+ s.rubygems_version = %q{1.3.4}
67
+ s.summary = %q{Battle-tested capistrano recipes for passenger, delayed_job, and more}
68
+ s.test_files = [
69
+ "spec/cap/helper.rb",
70
+ "spec/cap_recipes_spec.rb",
71
+ "spec/spec_helper.rb",
72
+ "examples/advanced/deploy/experimental.rb",
73
+ "examples/advanced/deploy/production.rb",
74
+ "examples/advanced/deploy.rb",
75
+ "examples/simple/deploy.rb"
76
+ ]
77
+
78
+ if s.respond_to? :specification_version then
79
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
80
+ s.specification_version = 3
81
+
82
+ if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
83
+ else
84
+ end
85
+ else
86
+ end
87
+ end