crazycode-cap-recipes 0.3.37
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENSE +20 -0
- data/README.textile +586 -0
- data/Rakefile +57 -0
- data/VERSION.yml +5 -0
- data/bin/cap-recipes +4 -0
- data/cap-recipes.gemspec +128 -0
- data/examples/advanced/deploy.rb +39 -0
- data/examples/advanced/deploy/experimental.rb +14 -0
- data/examples/advanced/deploy/production.rb +20 -0
- data/examples/simple/deploy.rb +36 -0
- data/lib/cap_recipes.rb +1 -0
- data/lib/cap_recipes/tasks/apache.rb +1 -0
- data/lib/cap_recipes/tasks/apache/install.rb +16 -0
- data/lib/cap_recipes/tasks/apache/manage.rb +26 -0
- data/lib/cap_recipes/tasks/aptitude.rb +1 -0
- data/lib/cap_recipes/tasks/aptitude/manage.rb +32 -0
- data/lib/cap_recipes/tasks/backgroundrb.rb +1 -0
- data/lib/cap_recipes/tasks/backgroundrb/hooks.rb +5 -0
- data/lib/cap_recipes/tasks/backgroundrb/manage.rb +64 -0
- data/lib/cap_recipes/tasks/bundler.rb +1 -0
- data/lib/cap_recipes/tasks/bundler/manage.rb +31 -0
- data/lib/cap_recipes/tasks/delayed_job.rb +1 -0
- data/lib/cap_recipes/tasks/delayed_job/hooks.rb +5 -0
- data/lib/cap_recipes/tasks/delayed_job/manage.rb +34 -0
- data/lib/cap_recipes/tasks/ec2/install.rb +32 -0
- data/lib/cap_recipes/tasks/ec2/manage.rb +32 -0
- data/lib/cap_recipes/tasks/gitosis.rb +1 -0
- data/lib/cap_recipes/tasks/gitosis/install.rb +58 -0
- data/lib/cap_recipes/tasks/gitosis/manage.rb +3 -0
- data/lib/cap_recipes/tasks/hudson.rb +1 -0
- data/lib/cap_recipes/tasks/hudson/manage.rb +33 -0
- data/lib/cap_recipes/tasks/jetty.rb +1 -0
- data/lib/cap_recipes/tasks/jetty/install.rb +33 -0
- data/lib/cap_recipes/tasks/jetty/manage.rb +34 -0
- data/lib/cap_recipes/tasks/jetty/web.rb +98 -0
- data/lib/cap_recipes/tasks/juggernaut.rb +3 -0
- data/lib/cap_recipes/tasks/juggernaut/hooks.rb +4 -0
- data/lib/cap_recipes/tasks/juggernaut/manage.rb +56 -0
- data/lib/cap_recipes/tasks/maven.rb +85 -0
- data/lib/cap_recipes/tasks/memcache.rb +3 -0
- data/lib/cap_recipes/tasks/memcache/hooks.rb +5 -0
- data/lib/cap_recipes/tasks/memcache/install.rb +15 -0
- data/lib/cap_recipes/tasks/memcache/manage.rb +37 -0
- data/lib/cap_recipes/tasks/mongodb.rb +1 -0
- data/lib/cap_recipes/tasks/mongodb/install.rb +137 -0
- data/lib/cap_recipes/tasks/mongodb/manage.rb +27 -0
- data/lib/cap_recipes/tasks/passenger.rb +1 -0
- data/lib/cap_recipes/tasks/passenger/install.rb +72 -0
- data/lib/cap_recipes/tasks/passenger/manage.rb +23 -0
- data/lib/cap_recipes/tasks/rails.rb +1 -0
- data/lib/cap_recipes/tasks/rails/hooks.rb +6 -0
- data/lib/cap_recipes/tasks/rails/manage.rb +51 -0
- data/lib/cap_recipes/tasks/ruby.rb +1 -0
- data/lib/cap_recipes/tasks/ruby/install.rb +16 -0
- data/lib/cap_recipes/tasks/rubygems.rb +1 -0
- data/lib/cap_recipes/tasks/rubygems/install.rb +22 -0
- data/lib/cap_recipes/tasks/rubygems/manage.rb +43 -0
- data/lib/cap_recipes/tasks/templates/hudson.erb +85 -0
- data/lib/cap_recipes/tasks/templates/mongod.conf.erb +89 -0
- data/lib/cap_recipes/tasks/templates/mongodb.init.erb +73 -0
- data/lib/cap_recipes/tasks/templates/mongodb.repo.erb +4 -0
- data/lib/cap_recipes/tasks/templates/mongos.init.erb +69 -0
- data/lib/cap_recipes/tasks/templates/tomcat.erb +95 -0
- data/lib/cap_recipes/tasks/thinking_sphinx.rb +1 -0
- data/lib/cap_recipes/tasks/thinking_sphinx/hooks.rb +4 -0
- data/lib/cap_recipes/tasks/thinking_sphinx/install.rb +17 -0
- data/lib/cap_recipes/tasks/thinking_sphinx/manage.rb +65 -0
- data/lib/cap_recipes/tasks/tomcat.rb +1 -0
- data/lib/cap_recipes/tasks/tomcat/install.rb +43 -0
- data/lib/cap_recipes/tasks/tomcat/manage.rb +34 -0
- data/lib/cap_recipes/tasks/tomcat/war.rb +98 -0
- data/lib/cap_recipes/tasks/utilities.rb +172 -0
- data/lib/cap_recipes/tasks/whenever.rb +1 -0
- data/lib/cap_recipes/tasks/whenever/hooks.rb +5 -0
- data/lib/cap_recipes/tasks/whenever/manage.rb +8 -0
- data/lib/cap_recipes/tasks/yum.rb +1 -0
- data/lib/cap_recipes/tasks/yum/manage.rb +30 -0
- data/lib/capify.rb +35 -0
- data/lib/templates/Capfile.tt +4 -0
- data/lib/templates/deploy.rb.tt +30 -0
- data/spec/cap/all/Capfile +2 -0
- data/spec/cap/helper.rb +3 -0
- data/spec/cap_recipes_spec.rb +56 -0
- data/spec/spec_helper.rb +37 -0
- data/specs.watchr +35 -0
- metadata +155 -0
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,586 @@
|
|
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
|
+
Worth noting is that the installation tasks are for systems using aptitude package management.
|
7
|
+
|
8
|
+
The overall vision for this project is simply to collect a number of classic, generic recipes
|
9
|
+
for common issues which can then be used by the community.
|
10
|
+
|
11
|
+
Feel free to improve upon this recipe collection by adding your own!
|
12
|
+
|
13
|
+
Currently included recipes in this gem:
|
14
|
+
|
15
|
+
* Ruby Setup
|
16
|
+
* Rubygems Management
|
17
|
+
* Apache Server
|
18
|
+
* Phusion Passenger
|
19
|
+
* Memcached Management
|
20
|
+
* ThinkingSphinx Daemon
|
21
|
+
* Juggernaut Daemon
|
22
|
+
* Backgroundrb Server
|
23
|
+
* DelayedJob Worker
|
24
|
+
* Whenever Cron Scheduling
|
25
|
+
* MongoDB Management
|
26
|
+
* Aptitude Package Management
|
27
|
+
* Gitosis Git Repository Hosting
|
28
|
+
* Mongodb Management
|
29
|
+
* Bundler Tasks
|
30
|
+
|
31
|
+
Check out the USAGE section below for specific tasks included in the recipes.
|
32
|
+
|
33
|
+
h2. INSTALLATION
|
34
|
+
|
35
|
+
To install the gem, execute:
|
36
|
+
|
37
|
+
@$ sudo gem install cap-recipes --source http://gemcutter.org@
|
38
|
+
|
39
|
+
Then, include into your @deploy.rb@ configuration file for Capistrano:
|
40
|
+
|
41
|
+
<pre><code>
|
42
|
+
# use the complete deployment process (NOT RECOMMENDED)
|
43
|
+
require 'cap_recipes'
|
44
|
+
|
45
|
+
# RECOMMENDED
|
46
|
+
# require necessary recipes according to your needs
|
47
|
+
# (use hooks which tie all the recipes into the deployment process,
|
48
|
+
# tasks for managing and tasks for installing):
|
49
|
+
require 'cap_recipes/tasks/memcache'
|
50
|
+
require 'cap_recipes/tasks/passenger'
|
51
|
+
require 'cap_recipes/tasks/thinking_sphinx'
|
52
|
+
require 'cap_recipes/tasks/rails'
|
53
|
+
require 'cap_recipes/tasks/delayed_job'
|
54
|
+
# or ruby, rubygems, apache, mongodb, juggernaut, backgroundrb, aptitude, gitosis, whenever
|
55
|
+
|
56
|
+
# OR
|
57
|
+
# only use managing tasks:
|
58
|
+
require 'cap_recipes/tasks/memcache/manage'
|
59
|
+
|
60
|
+
# OR
|
61
|
+
#only use install tasks:
|
62
|
+
require 'cap_recipes/tasks/memcache/install'
|
63
|
+
</code></pre>
|
64
|
+
|
65
|
+
You can find full examples of what your @deploy.rb@ file should look like in the @examples@ folder.
|
66
|
+
|
67
|
+
h2. USAGE
|
68
|
+
|
69
|
+
h3. Apache
|
70
|
+
|
71
|
+
These recipes manage the apache web server
|
72
|
+
|
73
|
+
h4. Configuration
|
74
|
+
|
75
|
+
|
76
|
+
* apache_init_path - the path to the init.d apache file [default: '/etc/init.d/apache2']
|
77
|
+
|
78
|
+
|
79
|
+
h4. Tasks
|
80
|
+
|
81
|
+
manage.rb
|
82
|
+
|
83
|
+
* apache:stop - stops the apache server
|
84
|
+
* apache:start - starts the apache server
|
85
|
+
* apache:restart - restarts the apache server
|
86
|
+
|
87
|
+
install.rb
|
88
|
+
|
89
|
+
* apache:install - installs apache and dependencies onto a debian system
|
90
|
+
|
91
|
+
h3. Ruby
|
92
|
+
|
93
|
+
h4. Configuration
|
94
|
+
|
95
|
+
|
96
|
+
* None required
|
97
|
+
|
98
|
+
|
99
|
+
h4. Tasks
|
100
|
+
|
101
|
+
install.rb
|
102
|
+
|
103
|
+
* ruby:setup - Installs ruby 1.8 using standard aptitude packages
|
104
|
+
|
105
|
+
h3. Rubygems
|
106
|
+
|
107
|
+
h4. Configuration
|
108
|
+
|
109
|
+
|
110
|
+
* rubygem_paths - a path or array of paths to your gem binaries [default '/usr/bin/gem' ]
|
111
|
+
* rubygems_version - which version of rubygems to install [default '1.3.5']
|
112
|
+
|
113
|
+
|
114
|
+
h4. Tasks
|
115
|
+
|
116
|
+
manage.rb
|
117
|
+
|
118
|
+
* rubygems:full_update - Upgrades rubygems, updates all installed rubygems and performs a cleanup
|
119
|
+
* rubygems:upgrade - Upgrades rubygems version (if available)
|
120
|
+
* rubygems:update - Updates all installed rubygems
|
121
|
+
* rubygems:cleanup - Performs a cleanup for all outdated rubygems
|
122
|
+
* rubygems:install - Installs a specifed gem from name inputted on console
|
123
|
+
* rubygems:uninstall - Removes a specified rubygem from name inputted on console
|
124
|
+
|
125
|
+
install.rb
|
126
|
+
|
127
|
+
* rubygems:install - Installs rubygems by downloading package and running setup.rb
|
128
|
+
|
129
|
+
h3. Passenger
|
130
|
+
|
131
|
+
These recipes manage the passenger module for apache
|
132
|
+
|
133
|
+
h4. Configuration
|
134
|
+
|
135
|
+
|
136
|
+
* base_ruby_path - the base path to the ruby installation [default: '/usr']
|
137
|
+
* local_ping_path - the localhost path to ping to start passenger [default: "http://localhost"]
|
138
|
+
|
139
|
+
The following files and folders are expected to exist:
|
140
|
+
|
141
|
+
* "#{base_ruby_path}/lib/ruby"
|
142
|
+
* "#{base_ruby_path}/bin/ruby"
|
143
|
+
* "#{base_ruby_path}/bin/gem"
|
144
|
+
|
145
|
+
|
146
|
+
h4. Tasks
|
147
|
+
|
148
|
+
manage.rb
|
149
|
+
|
150
|
+
* deploy:start - Starts the apache server (if needed)
|
151
|
+
* deploy:stop - Stops the apache server (if needed)
|
152
|
+
* deploy:restart - Touches the restart.txt file
|
153
|
+
|
154
|
+
install.rb
|
155
|
+
|
156
|
+
* passenger:install - Installs the passenger gem, compiles the module silently, and adds the necessary configuration
|
157
|
+
|
158
|
+
h3. Aptitude
|
159
|
+
|
160
|
+
h4. Tasks
|
161
|
+
|
162
|
+
manage.rb
|
163
|
+
|
164
|
+
* aptitude:install - Installs a specified aptitude package from name inputted on console
|
165
|
+
* aptitude:remove - Removes a specified aptitude package from name inputted on console
|
166
|
+
* aptitude:updates - Updates all installed aptitude packages
|
167
|
+
|
168
|
+
h3. Rails
|
169
|
+
|
170
|
+
These recipes support rails-specific functionality
|
171
|
+
|
172
|
+
h4. Tasks
|
173
|
+
|
174
|
+
manage.rb
|
175
|
+
|
176
|
+
* rails:symlink_db_config - Symlinks the database.yml file from shared/config to release path
|
177
|
+
* rails:repair_permissions - Forces the permissions on the rails app to make permission errors a thing of the past
|
178
|
+
* rails:tail - tail production log - Provides a stream tailing the production log
|
179
|
+
* rails:ping - pings the server to start a passenger instance (reduces downtime)
|
180
|
+
* rails:sweep:cache - performs a file cache sweep in production
|
181
|
+
* rails:sweep:log - performs a log sweep in production
|
182
|
+
|
183
|
+
hooks.rb
|
184
|
+
|
185
|
+
<pre><code>
|
186
|
+
after "deploy:update_code", "rails:symlink_db_config" # copy database.yml file to release path
|
187
|
+
after "deploy:update_code", "rails:sweep:cache" # clear cache after updating code
|
188
|
+
after "deploy:restart" , "rails:repair_permissions" # fix the permissions to work properly
|
189
|
+
after "deploy:restart" , "rails:ping" # ping passenger to start the rails instance
|
190
|
+
</code></pre>
|
191
|
+
|
192
|
+
h3. DelayedJob
|
193
|
+
|
194
|
+
These recipes are for tobi's delayed_job plugin for background job queue processing
|
195
|
+
|
196
|
+
h4. Configuration
|
197
|
+
|
198
|
+
|
199
|
+
* delayed_script_path - the path to the delayed job script [default: '#{current_path}/script/delayed_job']
|
200
|
+
* delayed_job_env - the rails environment [default: 'production']
|
201
|
+
|
202
|
+
|
203
|
+
h4. Tasks
|
204
|
+
|
205
|
+
manage.rb
|
206
|
+
|
207
|
+
* delayed_job:stop - stops the delayed_job workers
|
208
|
+
* delayed_job:start - starts the delayed_job workers
|
209
|
+
* delayed_job:restart - restarts the delayed_job workers
|
210
|
+
|
211
|
+
hooks.rb
|
212
|
+
|
213
|
+
<pre><code>
|
214
|
+
after "deploy:start", "delayed_job:start"
|
215
|
+
after "deploy:stop", "delayed_job:stop"
|
216
|
+
after "deploy:restart", "delayed_job:restart"
|
217
|
+
</code></pre>
|
218
|
+
|
219
|
+
h3. Backgroundrb
|
220
|
+
|
221
|
+
These recipes are for backgroundrb job queue processing
|
222
|
+
|
223
|
+
h4. Configuration
|
224
|
+
|
225
|
+
|
226
|
+
* backgroundrb_log - the path to the backgroundrb log file
|
227
|
+
* backgroundrb_host - the background host machine ip [default: 'localhost']
|
228
|
+
* backgroundrb_env - the rails environment [default: 'production']
|
229
|
+
|
230
|
+
|
231
|
+
h4. Tasks
|
232
|
+
|
233
|
+
manage.rb
|
234
|
+
|
235
|
+
* backgroundrb:stop - stop backgroundrb workers
|
236
|
+
* backgroundrb:start - start backgroundrb workers
|
237
|
+
* backgroundrb:restart - restart backgroundrb workers
|
238
|
+
* backgroundrb:symlink_config - copy backgroundrb.yml from shared/config to release
|
239
|
+
* backgroundrb:tail - tails the backgroundrb log file in production
|
240
|
+
|
241
|
+
hooks.rb
|
242
|
+
|
243
|
+
<pre><code>
|
244
|
+
after "deploy:update_code" , "backgroundrb:symlink_config" # copy backgroundrb config to release
|
245
|
+
after "deploy:restart" , "backgroundrb:restart" # restart backgroundrb daemon
|
246
|
+
after "backgroundrb:restart" , "backgroundrb:repair_permissions" # restart backgroundrb damon
|
247
|
+
</code></pre>
|
248
|
+
|
249
|
+
h3. Juggernaut
|
250
|
+
|
251
|
+
These recipes are for managing the juggernaut push server
|
252
|
+
|
253
|
+
h4. Configuration
|
254
|
+
|
255
|
+
|
256
|
+
* juggernaut_config - path to juggernaut config file [default: "#{current_path}/config/juggernaut.yml"]
|
257
|
+
* juggernaut_pid - path to juggernaut pid file [default: "#{current_path}/tmp/pids/juggernaut.pid"]
|
258
|
+
* juggernaut_log - path to juggernaut log file [default: "#{current_path}/log/juggernaut.log"]
|
259
|
+
|
260
|
+
|
261
|
+
h4. Tasks
|
262
|
+
|
263
|
+
manage.rb
|
264
|
+
|
265
|
+
* juggernaut:start - starts the juggernaut push server
|
266
|
+
* juggernaut:stop - stop the juggernaut push server
|
267
|
+
* juggernaut:restart - restart the juggernaut push server
|
268
|
+
* juggernaut:symlink_config - copy juggernaut.yml from shared/config to release
|
269
|
+
* juggernaut:tail - tails the juggernaut log file in production
|
270
|
+
|
271
|
+
hooks.rb
|
272
|
+
|
273
|
+
<pre><code>
|
274
|
+
after "deploy:update_code", "juggernaut:symlink_config" # copy juggernaut.yml to release
|
275
|
+
after "deploy:restart" , "juggernaut:restart" # restart juggernaut daemon
|
276
|
+
</code></pre>
|
277
|
+
|
278
|
+
h3. ThinkingSphinx
|
279
|
+
|
280
|
+
These recipes are for managing the thinking_sphinx search index daemon
|
281
|
+
|
282
|
+
h4. Configuration
|
283
|
+
|
284
|
+
|
285
|
+
* None required
|
286
|
+
|
287
|
+
|
288
|
+
h4. Tasks
|
289
|
+
|
290
|
+
manage.rb
|
291
|
+
|
292
|
+
* thinking_sphinx:start - starts the thinking_sphinx search daemon
|
293
|
+
* thinking_sphinx:index - executes the thinking_sphinx search indexer
|
294
|
+
* thinking_sphinx:stop - stop the thinking_sphinx search daemon
|
295
|
+
* thinking_sphinx:restart - restart (and index) the thinking_sphinx search daemon
|
296
|
+
* thinking_sphinx:symlink_config - copy sphinx.yml from shared/config to release
|
297
|
+
* thinking_sphinx:tail - tails the juggernaut log file in production
|
298
|
+
|
299
|
+
install.rb
|
300
|
+
|
301
|
+
* thinking_sphinx:install - installs sphinx, dependencies, and thinking_sphinx gem
|
302
|
+
|
303
|
+
hooks.rb
|
304
|
+
|
305
|
+
<pre><code>
|
306
|
+
after "deploy:update_code", "thinking_sphinx:symlink_config" # sym thinking_sphinx.yml on update code
|
307
|
+
after "deploy:restart" , "thinking_sphinx:restart" # restart thinking_sphinx on app restart
|
308
|
+
</code></pre>
|
309
|
+
|
310
|
+
h3. Memcache
|
311
|
+
|
312
|
+
These recipes are for managing the memcached caching mechanism
|
313
|
+
|
314
|
+
h4. Configuration
|
315
|
+
|
316
|
+
|
317
|
+
* memcache_init_path - path to memcache config file [default: "/etc/init.d/memcache"]
|
318
|
+
* memcache_size - the total size of memory to use [default: 64]
|
319
|
+
* memcache_port - the port to start memcache [default: '11211']
|
320
|
+
* memcache_host - the host for memcache [default: '127.0.0.1']
|
321
|
+
* memcache_user - the user to run memcache [default: 'nobody']
|
322
|
+
|
323
|
+
|
324
|
+
h4. Tasks
|
325
|
+
|
326
|
+
manage.rb
|
327
|
+
|
328
|
+
* memcache:start - starts the memcache daemon
|
329
|
+
* memcache:stop - stops the memcache daemon
|
330
|
+
* memcache:restart - restarts the memcache daemon
|
331
|
+
|
332
|
+
install.rb
|
333
|
+
|
334
|
+
* memcache:install - Installs memcache aptitude package and rubygem
|
335
|
+
|
336
|
+
hooks.rb
|
337
|
+
|
338
|
+
<pre><code>
|
339
|
+
after "deploy:restart", "memcache:restart" # clear cache after updating code
|
340
|
+
</code></pre>
|
341
|
+
|
342
|
+
h3. MongoDB
|
343
|
+
|
344
|
+
These recipes are for installing and managing the mongodb document-oriented database
|
345
|
+
|
346
|
+
h4. Configuration
|
347
|
+
|
348
|
+
* mongodb_data_path - the location to store the mongodb data [default: "/data/db"]
|
349
|
+
* mongodb_bin_path - the location to install mongodb [default: "/opt/mongo"]
|
350
|
+
* mongodb_log - the path to the mongodb log file [default: "/var/log/mongodb.log"]
|
351
|
+
|
352
|
+
h4. Tasks
|
353
|
+
|
354
|
+
install.rb
|
355
|
+
|
356
|
+
* mongodb:install - Performs the full installation of mongodb and dependencies
|
357
|
+
|
358
|
+
manage.rb
|
359
|
+
|
360
|
+
* mongodb:start - Starts the mongodb process
|
361
|
+
* mongodb:stop - Stops the mongodb process
|
362
|
+
* mongodb:restart - Restarts the mongodb process
|
363
|
+
|
364
|
+
h3. Gitosis
|
365
|
+
|
366
|
+
These recipes are for installing Gitosis Git Repository Hosting
|
367
|
+
|
368
|
+
h4. Configuration
|
369
|
+
|
370
|
+
|
371
|
+
* None required
|
372
|
+
|
373
|
+
|
374
|
+
h4. Tasks
|
375
|
+
|
376
|
+
install.rb
|
377
|
+
|
378
|
+
* gitosis:install
|
379
|
+
|
380
|
+
h3. Whenever
|
381
|
+
|
382
|
+
These recipes are for managing whenever cron job scheduling
|
383
|
+
|
384
|
+
h4. Configuration
|
385
|
+
|
386
|
+
|
387
|
+
* None required
|
388
|
+
|
389
|
+
|
390
|
+
h4. Tasks
|
391
|
+
|
392
|
+
manage.rb
|
393
|
+
|
394
|
+
* whenever:update_crontab - Performs an update applying the schedule.rb file to your server's cron
|
395
|
+
|
396
|
+
hooks.rb
|
397
|
+
|
398
|
+
<pre><code>
|
399
|
+
after "deploy:symlink", "whenever:update_crontab"
|
400
|
+
</code></pre>
|
401
|
+
|
402
|
+
|
403
|
+
h3. Bundler
|
404
|
+
|
405
|
+
These recipes are for managing bundler with your project
|
406
|
+
|
407
|
+
h4. Configuration
|
408
|
+
|
409
|
+
|
410
|
+
* None required
|
411
|
+
|
412
|
+
|
413
|
+
h4. Tasks
|
414
|
+
|
415
|
+
manage.rb
|
416
|
+
|
417
|
+
* bundle:install - Performs bundle install
|
418
|
+
* bundle:lock - Performs bundle lock
|
419
|
+
* bundle:unlock - Performs bundle unlock
|
420
|
+
* bundle:show - Performs bundle show
|
421
|
+
* bundle:check - Performs bundle check
|
422
|
+
hooks.rb
|
423
|
+
|
424
|
+
<pre><code>
|
425
|
+
after "deploy:symlink", "bundle:lock"
|
426
|
+
</code></pre>
|
427
|
+
|
428
|
+
|
429
|
+
|
430
|
+
|
431
|
+
h2. EXAMPLE
|
432
|
+
|
433
|
+
Here is a sample deploy.rb file using cap_recipes:
|
434
|
+
|
435
|
+
<pre><code>
|
436
|
+
# =============================================================================
|
437
|
+
# GENERAL SETTINGS
|
438
|
+
# =============================================================================
|
439
|
+
|
440
|
+
set :application, "app_name"
|
441
|
+
set :deploy_to, "/var/apps/#{application}"
|
442
|
+
set :scm, :git
|
443
|
+
set :repository, "git@repos.site.com:/home/git/repos.git"
|
444
|
+
|
445
|
+
# =============================================================================
|
446
|
+
# CAP RECIPES
|
447
|
+
# =============================================================================
|
448
|
+
|
449
|
+
# Note this happens after the general settings have been defined
|
450
|
+
require 'rubygems'
|
451
|
+
|
452
|
+
# PASSENGER
|
453
|
+
require 'cap_recipes/tasks/passenger'
|
454
|
+
set :base_ruby_path, '/opt/ruby-enterprise' # defaults to "/usr"
|
455
|
+
set :apache_init_path, '/etc/init.d/apache2' # defaults to "/etc/init.d/apache2"
|
456
|
+
|
457
|
+
# BACKGROUNDRB
|
458
|
+
require 'cap_recipes/tasks/backgroundrb'
|
459
|
+
set :backgroundrb_log, "/var/log/backgroundrb.log" # defaults to "#{release_path}/log/backgroundrb.log"
|
460
|
+
set :backgroundrb_host, "worker.site.com" # defaults to localhost
|
461
|
+
set :backgroundrb_env, "staging" # defaults to production
|
462
|
+
|
463
|
+
# DELAYED_JOB
|
464
|
+
require 'cap_recipes/tasks/delayed_job'
|
465
|
+
set :delayed_script_path, 'script/djworker' # defaults to 'script/delayed_job'
|
466
|
+
set :delayed_job_env, 'staging' # defaults to production
|
467
|
+
|
468
|
+
# JUGGERNAUT
|
469
|
+
require 'cap_recipes/tasks/juggernaut'
|
470
|
+
set :juggernaut_config, "/some/path/juggernaut.yml" # defaults to "#{current_path}/config/juggernaut.yml"
|
471
|
+
set :juggernaut_pid, "/some/path/juggernaut.pid" # defaults to "#{current_path}/tmp/pids/juggernaut.pid"
|
472
|
+
set :juggernaut_log, "/var/log/juggernaut.log" # defaults to #{release_path}/log/juggernaut.log
|
473
|
+
|
474
|
+
# MEMCACHE
|
475
|
+
require 'cap_recipes/tasks/memcache'
|
476
|
+
set :memcache_init_path, "/etc/init.d/memcache" # defaults to "/etc/init.d/memcache"
|
477
|
+
</code></pre>
|
478
|
+
|
479
|
+
You can find more examples of what your @deploy.rb@ file should look like in the @examples@ folder.
|
480
|
+
|
481
|
+
h2. UTILITIES
|
482
|
+
|
483
|
+
In addition to the recipes themselves, this gem provides a bunch of useful utility methods
|
484
|
+
which make writing your own recipes or extending existing ones much easier by creating reusable
|
485
|
+
commands for common subtasks in a recipe.
|
486
|
+
|
487
|
+
There are too many to mention all of them directly, but check out @lib/cap_recipes/tasks/utilities.rb@
|
488
|
+
to browse all available utility methods. A few are listed below:
|
489
|
+
|
490
|
+
* utilities.config_gsub(file, findPattern, replaceString)
|
491
|
+
** Replaces the @findPattern@ with @replaceString@ within specified file on server
|
492
|
+
** # utilities.config_gsub('/etc/example', /\#(option:.*?\n)/im, "\\1")
|
493
|
+
|
494
|
+
* utilities.ask(question, default)
|
495
|
+
** Asks the user a question on the command-line and returns the response
|
496
|
+
** utilities.ask('What is your name?', 'John')
|
497
|
+
|
498
|
+
* utilities.yes?(question)
|
499
|
+
** Asks the user a yes or no question on the command-line and returns boolean result
|
500
|
+
** utilities.yes?('Proceed with installation?')
|
501
|
+
|
502
|
+
* utilities.apt_install(packages)
|
503
|
+
** Installs all specified aptitude packages silently without user intervention
|
504
|
+
** utilities.apt_install %w[package1 package2]
|
505
|
+
|
506
|
+
* utilities.sudo_upload(local_path, remote_dest, options)
|
507
|
+
** Uploads a file to a temporary location and then sudo moves it to specified remote destination
|
508
|
+
** utilities.sudo_upload('/local/path/to/file', '/remote/path/to/destination', :mode => 'u+rwx')
|
509
|
+
|
510
|
+
* utilities.with_role(role) { ... }
|
511
|
+
** Forces tasks in block to execute only within specific role(s)
|
512
|
+
** This is useful because of certain limitations in the role declaration in capistrano
|
513
|
+
|
514
|
+
* utilities.with_credentials(:user => 'jsmith', :password => 'secret') { ... }
|
515
|
+
** Forces tasks in block to execute using the given user/password credentials
|
516
|
+
** This is useful because of certain limitations in capistrano
|
517
|
+
|
518
|
+
h2. CAP-RECIPES
|
519
|
+
|
520
|
+
cap-recipes allows you to create config with the desired recipes. It's capify for cap-recipes.
|
521
|
+
|
522
|
+
USAGE:
|
523
|
+
|
524
|
+
<code>
|
525
|
+
cap-recipes [path] [task1] [task2] [task3]
|
526
|
+
</code>
|
527
|
+
|
528
|
+
|
529
|
+
include memcache,apache, and passenger recipes
|
530
|
+
|
531
|
+
<code>
|
532
|
+
cap-recipes . memcache apache passenger
|
533
|
+
</code>
|
534
|
+
|
535
|
+
show all available recipes
|
536
|
+
|
537
|
+
<code>
|
538
|
+
cap-recipes --list | cap-recipes -l
|
539
|
+
</code>
|
540
|
+
|
541
|
+
show help
|
542
|
+
|
543
|
+
<code>
|
544
|
+
cap-recipes --help | cap-recipes -h
|
545
|
+
</code>
|
546
|
+
|
547
|
+
generate standard capify
|
548
|
+
|
549
|
+
<code>
|
550
|
+
cap-recipes . | cap-recipes
|
551
|
+
</code>
|
552
|
+
|
553
|
+
this defaults path to '.'
|
554
|
+
|
555
|
+
h2. CONTRIBUTORS
|
556
|
+
|
557
|
+
The following people are the reason this library exists:
|
558
|
+
|
559
|
+
* nesquena [Nathan Esquenazi] - created and maintaining the library
|
560
|
+
* achiu [Arthur Chiu] - contributed gitosis, ruby, mongodb and other recipes
|
561
|
+
* hubertlepicki - contributed thinking_sphinx recipes
|
562
|
+
|
563
|
+
h2. LICENSE
|
564
|
+
|
565
|
+
(The MIT License)
|
566
|
+
|
567
|
+
Copyright (c) 2008 Nathan Esquenazi
|
568
|
+
|
569
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
570
|
+
a copy of this software and associated documentation files (the
|
571
|
+
'Software'), to deal in the Software without restriction, including
|
572
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
573
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
574
|
+
permit persons to whom the Software is furnished to do so, subject to
|
575
|
+
the following conditions:
|
576
|
+
|
577
|
+
The above copyright notice and this permission notice shall be
|
578
|
+
included in all copies or substantial portions of the Software.
|
579
|
+
|
580
|
+
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
581
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
582
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
583
|
+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
584
|
+
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
585
|
+
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
586
|
+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|