capium 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENSE +20 -0
- data/lib/capium.rb +514 -0
- metadata +6 -4
data/LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2011 Mehdi Lahmam B.
|
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/lib/capium.rb
ADDED
@@ -0,0 +1,514 @@
|
|
1
|
+
Capistrano::Configuration.instance(:must_exist).load do
|
2
|
+
require 'benchmark'
|
3
|
+
require 'capistrano/recipes/deploy/scm'
|
4
|
+
require 'capistrano/recipes/deploy/strategy'
|
5
|
+
|
6
|
+
def _cset(name, *args, &block)
|
7
|
+
unless exists?(name)
|
8
|
+
set(name, *args, &block)
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
# =========================================================================
|
13
|
+
# These variables MUST be set in the client capfiles. If they are not set,
|
14
|
+
# the deploy will fail with an error.
|
15
|
+
# =========================================================================
|
16
|
+
|
17
|
+
_cset(:application) { abort "Please specify the name of your application, set :application, 'foo'" }
|
18
|
+
_cset(:repository) { abort "Please specify the repository that houses your application's code, set :repository, 'foo'" }
|
19
|
+
|
20
|
+
# =========================================================================
|
21
|
+
# These variables may be set in the client capfile if their default values
|
22
|
+
# are not sufficient.
|
23
|
+
# =========================================================================
|
24
|
+
|
25
|
+
_cset :scm, :subversion
|
26
|
+
_cset :deploy_via, :checkout
|
27
|
+
|
28
|
+
_cset(:deploy_to) { "/u/apps/#{application}" }
|
29
|
+
_cset(:revision) { source.head }
|
30
|
+
|
31
|
+
# Lithium variables
|
32
|
+
_cset(:lithium_repo) { "git://github.com/UnionOfRAD/lithium.git"}
|
33
|
+
_cset(:lithium_branch) { "master" }
|
34
|
+
_cset :lithium_env, "production"
|
35
|
+
_cset(:run_lithium_tests) { false }
|
36
|
+
|
37
|
+
# =========================================================================
|
38
|
+
# These variables should NOT be changed unless you are very confident in
|
39
|
+
# what you are doing. Make sure you understand all the implications of your
|
40
|
+
# changes if you do decide to muck with these!
|
41
|
+
# =========================================================================
|
42
|
+
|
43
|
+
_cset(:source) { Capistrano::Deploy::SCM.new(scm, self) }
|
44
|
+
_cset(:real_revision) { source.local.query_revision(revision) { |cmd| with_env("LC_ALL", "C") { run_locally(cmd) } } }
|
45
|
+
|
46
|
+
_cset(:strategy) { Capistrano::Deploy::Strategy.new(deploy_via, self) }
|
47
|
+
|
48
|
+
# If overriding release name, please also select an appropriate setting for :releases below.
|
49
|
+
_cset(:release_name) { set :deploy_timestamped, true; Time.now.utc.strftime("%Y%m%d%H%M%S") }
|
50
|
+
|
51
|
+
_cset :version_dir, "releases"
|
52
|
+
_cset :shared_dir, "shared"
|
53
|
+
_cset :shared_children, ['libraries']
|
54
|
+
_cset :current_dir, "current"
|
55
|
+
|
56
|
+
_cset(:releases_path) { File.join(deploy_to, version_dir) }
|
57
|
+
_cset(:shared_path) { File.join(deploy_to, shared_dir) }
|
58
|
+
_cset(:current_path) { File.join(deploy_to, current_dir) }
|
59
|
+
_cset(:release_path) { File.join(releases_path, release_name) }
|
60
|
+
|
61
|
+
_cset(:releases) { capture("ls -x #{releases_path}", :except => { :no_release => true }).split.sort }
|
62
|
+
_cset(:current_release) { releases.length > 0 ? File.join(releases_path, releases.last) : nil }
|
63
|
+
_cset(:previous_release) { releases.length > 1 ? File.join(releases_path, releases[-2]) : nil }
|
64
|
+
|
65
|
+
_cset(:current_revision) { capture("cat #{current_path}/REVISION", :except => { :no_release => true }).chomp }
|
66
|
+
_cset(:latest_revision) { capture("cat #{current_release}/REVISION", :except => { :no_release => true }).chomp }
|
67
|
+
_cset(:previous_revision) { capture("cat #{previous_release}/REVISION", :except => { :no_release => true }).chomp if previous_release }
|
68
|
+
|
69
|
+
_cset(:run_method) { fetch(:use_sudo, true) ? :sudo : :run }
|
70
|
+
|
71
|
+
# some tasks, like symlink, need to always point at the latest release, but
|
72
|
+
# they can also (occassionally) be called standalone. In the standalone case,
|
73
|
+
# the timestamped release_path will be inaccurate, since the directory won't
|
74
|
+
# actually exist. This variable lets tasks like symlink work either in the
|
75
|
+
# standalone case, or during deployment.
|
76
|
+
_cset(:latest_release) { exists?(:deploy_timestamped) ? release_path : current_release }
|
77
|
+
|
78
|
+
# =========================================================================
|
79
|
+
# These are helper methods that will be available to your recipes.
|
80
|
+
# =========================================================================
|
81
|
+
|
82
|
+
# Auxiliary helper method for the `deploy:check' task. Lets you set up your
|
83
|
+
# own dependencies.
|
84
|
+
def depend(location, type, *args)
|
85
|
+
deps = fetch(:dependencies, {})
|
86
|
+
deps[location] ||= {}
|
87
|
+
deps[location][type] ||= []
|
88
|
+
deps[location][type] << args
|
89
|
+
set :dependencies, deps
|
90
|
+
end
|
91
|
+
|
92
|
+
# Temporarily sets an environment variable, yields to a block, and restores
|
93
|
+
# the value when it is done.
|
94
|
+
def with_env(name, value)
|
95
|
+
saved, ENV[name] = ENV[name], value
|
96
|
+
yield
|
97
|
+
ensure
|
98
|
+
ENV[name] = saved
|
99
|
+
end
|
100
|
+
|
101
|
+
# logs the command then executes it locally.
|
102
|
+
# returns the command output as a string
|
103
|
+
def run_locally(cmd)
|
104
|
+
logger.trace "executing locally: #{cmd.inspect}" if logger
|
105
|
+
output_on_stdout = nil
|
106
|
+
elapsed = Benchmark.realtime do
|
107
|
+
output_on_stdout = `#{cmd}`
|
108
|
+
end
|
109
|
+
if $?.to_i > 0 # $? is command exit code (posix style)
|
110
|
+
raise Capistrano::LocalArgumentError, "Command #{cmd} returned status code #{$?}"
|
111
|
+
end
|
112
|
+
logger.trace "command finished in #{(elapsed * 1000).round}ms" if logger
|
113
|
+
output_on_stdout
|
114
|
+
end
|
115
|
+
|
116
|
+
# If a command is given, this will try to execute the given command, as
|
117
|
+
# described below. Otherwise, it will return a string for use in embedding in
|
118
|
+
# another command, for executing that command as described below.
|
119
|
+
#
|
120
|
+
# If :run_method is :sudo (or :use_sudo is true), this executes the given command
|
121
|
+
# via +sudo+. Otherwise is uses +run+. If :as is given as a key, it will be
|
122
|
+
# passed as the user to sudo as, if using sudo. If the :as key is not given,
|
123
|
+
# it will default to whatever the value of the :admin_runner variable is,
|
124
|
+
# which (by default) is unset.
|
125
|
+
#
|
126
|
+
# THUS, if you want to try to run something via sudo, and what to use the
|
127
|
+
# root user, you'd just to try_sudo('something'). If you wanted to try_sudo as
|
128
|
+
# someone else, you'd just do try_sudo('something', :as => "bob"). If you
|
129
|
+
# always wanted sudo to run as a particular user, you could do
|
130
|
+
# set(:admin_runner, "bob").
|
131
|
+
def try_sudo(*args)
|
132
|
+
options = args.last.is_a?(Hash) ? args.pop : {}
|
133
|
+
command = args.shift
|
134
|
+
raise ArgumentError, "too many arguments" if args.any?
|
135
|
+
|
136
|
+
as = options.fetch(:as, fetch(:admin_runner, nil))
|
137
|
+
via = fetch(:run_method, :sudo)
|
138
|
+
if command
|
139
|
+
invoke_command(command, :via => via, :as => as)
|
140
|
+
elsif via == :sudo
|
141
|
+
sudo(:as => as)
|
142
|
+
else
|
143
|
+
""
|
144
|
+
end
|
145
|
+
end
|
146
|
+
|
147
|
+
# Same as sudo, but tries sudo with :as set to the value of the :runner
|
148
|
+
# variable (which defaults to "app").
|
149
|
+
def try_runner(*args)
|
150
|
+
options = args.last.is_a?(Hash) ? args.pop : {}
|
151
|
+
args << options.merge(:as => fetch(:runner, "app"))
|
152
|
+
try_sudo(*args)
|
153
|
+
end
|
154
|
+
|
155
|
+
|
156
|
+
def capium()
|
157
|
+
set :deploy_to, "/var/www/#{application}" if (deploy_to.empty?)
|
158
|
+
after("deploy:setup", "lithium:setup")
|
159
|
+
after("deploy:symlink", "lithium:configure_library_path", "lithium:clear_cache")
|
160
|
+
end
|
161
|
+
|
162
|
+
# =========================================================================
|
163
|
+
# These are the tasks that are available to help with deploying web apps,
|
164
|
+
# and specifically, Rails applications. You can have cap give you a summary
|
165
|
+
# of them with `cap -T'.
|
166
|
+
# =========================================================================
|
167
|
+
|
168
|
+
namespace :deploy do
|
169
|
+
desc <<-DESC
|
170
|
+
Deploys your project. Handy wrapper to hook into the beginning of the deployment. Note that \
|
171
|
+
this will generally only work for applications that have already been deployed \
|
172
|
+
once. For a "cold" deploy, you'll want to take a look at the `deploy:cold' \
|
173
|
+
task, which handles the cold start specifically.
|
174
|
+
DESC
|
175
|
+
task :default do
|
176
|
+
update
|
177
|
+
end
|
178
|
+
|
179
|
+
desc <<-DESC
|
180
|
+
Prepares one or more servers for deployment. Before you can use any \
|
181
|
+
of the Capistrano deployment tasks with your project, you will need to \
|
182
|
+
make sure all of your servers have been prepared with `cap deploy:setup'. When \
|
183
|
+
you add a new server to your cluster, you can easily run the setup task \
|
184
|
+
on just that server by specifying the HOSTS environment variable:
|
185
|
+
|
186
|
+
$ cap HOSTS=new.server.com deploy:setup
|
187
|
+
|
188
|
+
It is safe to run this task on servers that have already been set up; it \
|
189
|
+
will not destroy any deployed revisions or data.
|
190
|
+
DESC
|
191
|
+
task :setup, :except => { :no_release => true } do
|
192
|
+
dirs = [deploy_to, releases_path, shared_path]
|
193
|
+
dirs += shared_children.map { |d| File.join(shared_path, d) }
|
194
|
+
run "#{try_sudo} mkdir -p #{dirs.join(' ')} && #{try_sudo} chmod g+w #{dirs.join(' ')}"
|
195
|
+
end
|
196
|
+
|
197
|
+
desc <<-DESC
|
198
|
+
Copies your project and updates the symlink. It does this in a \
|
199
|
+
transaction, so that if either `update_code' or `symlink' fail, all \
|
200
|
+
changes made to the remote servers will be rolled back, leaving your \
|
201
|
+
system in the same state it was in before `update' was invoked. Usually, \
|
202
|
+
you will want to call `deploy' instead of `update', but `update' can be \
|
203
|
+
handy if you want to deploy, but not immediately restart your application.
|
204
|
+
DESC
|
205
|
+
task :update do
|
206
|
+
transaction do
|
207
|
+
update_code
|
208
|
+
symlink
|
209
|
+
end
|
210
|
+
end
|
211
|
+
|
212
|
+
desc <<-DESC
|
213
|
+
Copies your project to the remote servers. This is the first stage \
|
214
|
+
of any deployment; moving your updated code and assets to the deployment \
|
215
|
+
servers. You will rarely call this task directly, however; instead, you \
|
216
|
+
should call the `deploy' task (to do a complete deploy) or the `update' \
|
217
|
+
task (if you want to perform the `restart' task separately).
|
218
|
+
|
219
|
+
You will need to make sure you set the :scm variable to the source \
|
220
|
+
control software you are using (it defaults to :subversion), and the \
|
221
|
+
:deploy_via variable to the strategy you want to use to deploy (it \
|
222
|
+
defaults to :checkout).
|
223
|
+
DESC
|
224
|
+
task :update_code, :except => { :no_release => true } do
|
225
|
+
on_rollback { run "rm -rf #{release_path}; true" }
|
226
|
+
strategy.deploy!
|
227
|
+
finalize_update
|
228
|
+
end
|
229
|
+
|
230
|
+
desc <<-DESC
|
231
|
+
[internal] Touches up the released code. This is called by update_code \
|
232
|
+
after the basic deploy finishes. It assumes a Rails project was deployed, \
|
233
|
+
so if you are deploying something else, you may want to override this \
|
234
|
+
task with your own environment's requirements.
|
235
|
+
|
236
|
+
This task will make the release group-writable (if the :group_writable \
|
237
|
+
variable is set to true, which is the default). It will then set up \
|
238
|
+
symlinks to the shared directory for the log, system, and tmp/pids \
|
239
|
+
directories, and will lastly touch all assets in public/images, \
|
240
|
+
public/stylesheets, and public/javascripts so that the times are \
|
241
|
+
consistent (so that asset timestamping works). This touch process \
|
242
|
+
is only carried out if the :normalize_asset_timestamps variable is \
|
243
|
+
set to true, which is the default.
|
244
|
+
DESC
|
245
|
+
task :finalize_update, :except => { :no_release => true } do
|
246
|
+
run "chmod -R g+w #{latest_release}" if fetch(:group_writable, true)
|
247
|
+
end
|
248
|
+
|
249
|
+
desc <<-DESC
|
250
|
+
Updates the symlink to the most recently deployed version. Capistrano works \
|
251
|
+
by putting each new release of your application in its own directory. When \
|
252
|
+
you deploy a new version, this task's job is to update the `current' symlink \
|
253
|
+
to point at the new version. You will rarely need to call this task \
|
254
|
+
directly; instead, use the `deploy' task (which performs a complete \
|
255
|
+
deploy, including `restart') or the 'update' task (which does everything \
|
256
|
+
except `restart').
|
257
|
+
DESC
|
258
|
+
task :symlink, :except => { :no_release => true } do
|
259
|
+
on_rollback do
|
260
|
+
if previous_release
|
261
|
+
run "rm -f #{current_path}; ln -s #{previous_release} #{current_path}; true"
|
262
|
+
else
|
263
|
+
logger.important "no previous release to rollback to, rollback of symlink skipped"
|
264
|
+
end
|
265
|
+
end
|
266
|
+
|
267
|
+
run "rm -f #{current_path} && ln -s #{latest_release} #{current_path}"
|
268
|
+
end
|
269
|
+
|
270
|
+
desc <<-DESC
|
271
|
+
Copy files to the currently deployed version. This is useful for updating \
|
272
|
+
files piecemeal, such as when you need to quickly deploy only a single \
|
273
|
+
file. Some files, such as updated templates, images, or stylesheets, \
|
274
|
+
might not require a full deploy, and especially in emergency situations \
|
275
|
+
it can be handy to just push the updates to production, quickly.
|
276
|
+
|
277
|
+
To use this task, specify the files and directories you want to copy as a \
|
278
|
+
comma-delimited list in the FILES environment variable. All directories \
|
279
|
+
will be processed recursively, with all files being pushed to the \
|
280
|
+
deployment servers.
|
281
|
+
|
282
|
+
$ cap deploy:upload FILES=templates,controller.rb
|
283
|
+
|
284
|
+
Dir globs are also supported:
|
285
|
+
|
286
|
+
$ cap deploy:upload FILES='config/apache/*.conf'
|
287
|
+
DESC
|
288
|
+
task :upload, :except => { :no_release => true } do
|
289
|
+
files = (ENV["FILES"] || "").split(",").map { |f| Dir[f.strip] }.flatten
|
290
|
+
abort "Please specify at least one file or directory to update (via the FILES environment variable)" if files.empty?
|
291
|
+
|
292
|
+
files.each { |file| top.upload(file, File.join(current_path, file)) }
|
293
|
+
end
|
294
|
+
|
295
|
+
namespace :rollback do
|
296
|
+
desc <<-DESC
|
297
|
+
[internal] Points the current symlink at the previous revision.
|
298
|
+
This is called by the rollback sequence, and should rarely (if
|
299
|
+
ever) need to be called directly.
|
300
|
+
DESC
|
301
|
+
task :revision, :except => { :no_release => true } do
|
302
|
+
if previous_release
|
303
|
+
run "rm #{current_path}; ln -s #{previous_release} #{current_path}"
|
304
|
+
else
|
305
|
+
abort "could not rollback the code because there is no prior release"
|
306
|
+
end
|
307
|
+
end
|
308
|
+
|
309
|
+
desc <<-DESC
|
310
|
+
[internal] Removes the most recently deployed release.
|
311
|
+
This is called by the rollback sequence, and should rarely
|
312
|
+
(if ever) need to be called directly.
|
313
|
+
DESC
|
314
|
+
task :cleanup, :except => { :no_release => true } do
|
315
|
+
run "if [ `readlink #{current_path}` != #{current_release} ]; then rm -rf #{current_release}; fi"
|
316
|
+
end
|
317
|
+
|
318
|
+
desc <<-DESC
|
319
|
+
Rolls back to the previously deployed version. The `current' symlink will \
|
320
|
+
be updated to point at the previously deployed version, and then the \
|
321
|
+
current release will be removed from the servers.
|
322
|
+
DESC
|
323
|
+
task :code, :except => { :no_release => true } do
|
324
|
+
revision
|
325
|
+
cleanup
|
326
|
+
end
|
327
|
+
|
328
|
+
desc <<-DESC
|
329
|
+
Rolls back to a previous version and restarts. This is handy if you ever \
|
330
|
+
discover that you've deployed a lemon; `cap rollback' and you're right \
|
331
|
+
back where you were, on the previously deployed version.
|
332
|
+
DESC
|
333
|
+
task :default do
|
334
|
+
revision
|
335
|
+
cleanup
|
336
|
+
end
|
337
|
+
end
|
338
|
+
|
339
|
+
desc <<-DESC
|
340
|
+
Clean up old releases. By default, the last 5 releases are kept on each \
|
341
|
+
server (though you can change this with the keep_releases variable). All \
|
342
|
+
other deployed revisions are removed from the servers. By default, this \
|
343
|
+
will use sudo to clean up the old releases, but if sudo is not available \
|
344
|
+
for your environment, set the :use_sudo variable to false instead.
|
345
|
+
DESC
|
346
|
+
task :cleanup, :except => { :no_release => true } do
|
347
|
+
count = fetch(:keep_releases, 5).to_i
|
348
|
+
if count >= releases.length
|
349
|
+
logger.important "no old releases to clean up"
|
350
|
+
else
|
351
|
+
logger.info "keeping #{count} of #{releases.length} deployed releases"
|
352
|
+
|
353
|
+
directories = (releases - releases.last(count)).map { |release|
|
354
|
+
File.join(releases_path, release) }.join(" ")
|
355
|
+
|
356
|
+
try_sudo "rm -rf #{directories}"
|
357
|
+
end
|
358
|
+
end
|
359
|
+
|
360
|
+
desc <<-DESC
|
361
|
+
Test deployment dependencies. Checks things like directory permissions, \
|
362
|
+
necessary utilities, and so forth, reporting on the things that appear to \
|
363
|
+
be incorrect or missing. This is good for making sure a deploy has a \
|
364
|
+
chance of working before you actually run `cap deploy'.
|
365
|
+
|
366
|
+
You can define your own dependencies, as well, using the `depend' method:
|
367
|
+
|
368
|
+
depend :remote, :gem, "tzinfo", ">=0.3.3"
|
369
|
+
depend :local, :command, "svn"
|
370
|
+
depend :remote, :directory, "/u/depot/files"
|
371
|
+
DESC
|
372
|
+
task :check, :except => { :no_release => true } do
|
373
|
+
dependencies = strategy.check!
|
374
|
+
|
375
|
+
other = fetch(:dependencies, {})
|
376
|
+
other.each do |location, types|
|
377
|
+
types.each do |type, calls|
|
378
|
+
if type == :gem
|
379
|
+
dependencies.send(location).command(fetch(:gem_command, "gem")).or("`gem' command could not be found. Try setting :gem_command")
|
380
|
+
end
|
381
|
+
|
382
|
+
calls.each do |args|
|
383
|
+
dependencies.send(location).send(type, *args)
|
384
|
+
end
|
385
|
+
end
|
386
|
+
end
|
387
|
+
|
388
|
+
if dependencies.pass?
|
389
|
+
puts "You appear to have all necessary dependencies installed"
|
390
|
+
else
|
391
|
+
puts "The following dependencies failed. Please check them and try again:"
|
392
|
+
dependencies.reject { |d| d.pass? }.each do |d|
|
393
|
+
puts "--> #{d.message}"
|
394
|
+
end
|
395
|
+
abort
|
396
|
+
end
|
397
|
+
end
|
398
|
+
|
399
|
+
desc <<-DESC
|
400
|
+
Deploys and starts a `cold' application. This is useful if you have not \
|
401
|
+
deployed your application before, or if your application is (for some \
|
402
|
+
other reason) not currently running. It will deploy the code, run any \
|
403
|
+
pending migrations, and then instead of invoking `deploy:restart', it will \
|
404
|
+
invoke `deploy:start' to fire up the application servers.
|
405
|
+
DESC
|
406
|
+
task :cold do
|
407
|
+
update
|
408
|
+
end
|
409
|
+
|
410
|
+
namespace :pending do
|
411
|
+
desc <<-DESC
|
412
|
+
Displays the `diff' since your last deploy. This is useful if you want \
|
413
|
+
to examine what changes are about to be deployed. Note that this might \
|
414
|
+
not be supported on all SCM's.
|
415
|
+
DESC
|
416
|
+
task :diff, :except => { :no_release => true } do
|
417
|
+
system(source.local.diff(current_revision))
|
418
|
+
end
|
419
|
+
|
420
|
+
desc <<-DESC
|
421
|
+
Displays the commits since your last deploy. This is good for a summary \
|
422
|
+
of the changes that have occurred since the last deploy. Note that this \
|
423
|
+
might not be supported on all SCM's.
|
424
|
+
DESC
|
425
|
+
task :default, :except => { :no_release => true } do
|
426
|
+
from = source.next_revision(current_revision)
|
427
|
+
system(source.local.log(from))
|
428
|
+
end
|
429
|
+
end
|
430
|
+
|
431
|
+
end
|
432
|
+
|
433
|
+
namespace :lithium do
|
434
|
+
|
435
|
+
desc <<-DESC
|
436
|
+
Prepares server for deployment of a Lithium application. \
|
437
|
+
|
438
|
+
By default, it will create a shallow clone of the Lithium repository \
|
439
|
+
inside {shared_path}/libraries/lithium and run deploy:lithium:update.
|
440
|
+
|
441
|
+
For more info about shallow clones: \
|
442
|
+
http://www.kernel.org/pub/software/scm/git/docs/git-clone.html \
|
443
|
+
|
444
|
+
Further customization will require that you write your own task.
|
445
|
+
DESC
|
446
|
+
task :setup do
|
447
|
+
run "cd #{shared_path}/libraries && git clone --depth 1 #{lithium_repo} lithium"
|
448
|
+
set :git_flag_quiet, "-q "
|
449
|
+
update
|
450
|
+
if run_lithium_tests
|
451
|
+
# test_core
|
452
|
+
end
|
453
|
+
end
|
454
|
+
desc <<-DESC
|
455
|
+
Force Lithium installation to checkout a new branch/tag. \
|
456
|
+
|
457
|
+
By default, it will checkout the :lithium_branch you set in \
|
458
|
+
deploy.rb, but you can change that on runtime by specifying \
|
459
|
+
the BRANCH environment variable:
|
460
|
+
|
461
|
+
$ cap deploy:lithium:update \\
|
462
|
+
BRANCH="lithium-0.10"
|
463
|
+
|
464
|
+
Further customization will require that you write your own task.
|
465
|
+
DESC
|
466
|
+
task :update do
|
467
|
+
set :lithium_branch, ENV['BRANCH'] if ENV.has_key?('BRANCH')
|
468
|
+
stream "cd #{shared_path}/libraries/lithium && git checkout #{git_flag_quiet}#{lithium_branch}"
|
469
|
+
end
|
470
|
+
|
471
|
+
desc <<-DESC
|
472
|
+
Run Lithium core tests
|
473
|
+
DESC
|
474
|
+
task :test_core do
|
475
|
+
set :li3_console, "#{shared_path}/libraries/lithium/console/li3"
|
476
|
+
set :li3_console_options, "--env=#{lithium_env}"
|
477
|
+
run "#{li3_console} test #{shared_path}/libraries/lithium/tests --env=#{lithium_env}"
|
478
|
+
end
|
479
|
+
|
480
|
+
desc <<-DESC
|
481
|
+
Run app tests
|
482
|
+
DESC
|
483
|
+
task :test_app do
|
484
|
+
set :li3_console, "#{shared_path}/libraries/lithium/console/li3"
|
485
|
+
set :li3_console_options, "--env=#{lithium_env}"
|
486
|
+
run "cd #{latest_release} && #{li3_console} test tests --env=#{lithium_env}"
|
487
|
+
end
|
488
|
+
|
489
|
+
desc <<-DESC
|
490
|
+
Sets the path to the class libraries used by your Lithium application. \
|
491
|
+
This directory contain a copy of the Lithium core.
|
492
|
+
DESC
|
493
|
+
task :configure_library_path do
|
494
|
+
run "sed -i \"s=^define('LITHIUM_LIBRARY_PATH.*$=define('LITHIUM_LIBRARY_PATH', '#{shared_path}/libraries');=\" #{release_path}/config/bootstrap/libraries.php"
|
495
|
+
end
|
496
|
+
|
497
|
+
desc <<-DESC
|
498
|
+
Blow up all the cache files Lithium uses, ensuring a clean restart.
|
499
|
+
DESC
|
500
|
+
task :clear_cache do
|
501
|
+
run "rm -rf #{release_path}/resources/tmp/*"
|
502
|
+
|
503
|
+
run [
|
504
|
+
"mkdir -p #{release_path}/resources/tmp/cache/templates",
|
505
|
+
"mkdir -p #{release_path}/resources/tmp/logs",
|
506
|
+
"mkdir -p #{release_path}/resources/tmp/tests",
|
507
|
+
|
508
|
+
"chmod -R 777 #{release_path}/resources",
|
509
|
+
].join(' && ')
|
510
|
+
end
|
511
|
+
|
512
|
+
end
|
513
|
+
|
514
|
+
end # Capistrano::Configuration.instance(:must_exist).load do
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: capium
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2011-
|
12
|
+
date: 2011-10-15 00:00:00.000000000Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: capistrano
|
16
|
-
requirement: &
|
16
|
+
requirement: &70094773609920 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ~>
|
@@ -21,7 +21,7 @@ dependencies:
|
|
21
21
|
version: 2.8.0
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *70094773609920
|
25
25
|
description: Lithium app deployment using Capistrano made easy
|
26
26
|
email: mehdi@lahmam.com
|
27
27
|
executables: []
|
@@ -29,6 +29,8 @@ extensions: []
|
|
29
29
|
extra_rdoc_files: []
|
30
30
|
files:
|
31
31
|
- README.md
|
32
|
+
- LICENSE
|
33
|
+
- lib/capium.rb
|
32
34
|
homepage: http://rubygems.org/gems/capium
|
33
35
|
licenses: []
|
34
36
|
post_install_message:
|