-
Notifications
You must be signed in to change notification settings - Fork 0
/
Magento-Recipe.rb
76 lines (64 loc) · 2.96 KB
/
Magento-Recipe.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
set :app_symlinks, ["/media", "/var", "/sitemaps", "/staging"]
set :app_shared_dirs, ["/app/etc", "/sitemaps", "/media", "/var", "/staging"]
set :app_shared_files, ["/app/etc/local.xml"]
namespace :mage do
desc <<-DESC
Prepares one or more servers for deployment of Magento. Before you can use any \
of the Capistrano deployment tasks with your project, you will need to \
make sure all of your servers have been prepared with `cap deploy:setup'. When \
you add a new server to your cluster, you can easily run the setup task \
on just that server by specifying the HOSTS environment variable:
$ cap HOSTS=new.server.com mage:setup
It is safe to run this task on servers that have already been set up; it \
will not destroy any deployed revisions or data.
DESC
task :setup, :roles => :web, :except => { :no_release => true } do
if app_shared_dirs
app_shared_dirs.each { |link| run "#{try_sudo} mkdir -p #{shared_path}#{link} && chmod 777 #{shared_path}#{link}" }
end
if app_shared_files
app_shared_files.each { |link| run "#{try_sudo} touch #{shared_path}#{link} && chmod 777 #{shared_path}#{link}" }
end
end
desc <<-DESC
Touches up the released code. This is called by update_code \
after the basic deploy finishes.
Any directories deployed from the SCM are first removed and then replaced with \
symlinks to the same directories within the shared location.
DESC
task :finalize_update, :roles => :web, :except => { :no_release => true } do
run "chmod -R g+w #{latest_release}" if fetch(:group_writable, true)
if app_symlinks
# Remove the contents of the shared directories if they were deployed from SCM
app_symlinks.each { |link| run "#{try_sudo} rm -rf #{latest_release}#{link}" }
# Add symlinks the directoris in the shared location
app_symlinks.each { |link| run "ln -nfs #{shared_path}#{link} #{latest_release}#{link}" }
end
if app_shared_files
# Remove the contents of the shared directories if they were deployed from SCM
app_shared_files.each { |link| run "#{try_sudo} rm -rf #{latest_release}/#{link}" }
# Add symlinks the directoris in the shared location
app_shared_files.each { |link| run "ln -s #{shared_path}#{link} #{latest_release}#{link}" }
end
end
desc <<-DESC
Clear the Magento Cache
DESC
task :cc, :roles => :web do
run "cd #{current_path} && rm -rf var/cache/*"
end
desc <<-DESC
Disable the Magento install by creating the maintenance.flag in the web root.
DESC
task :disable, :roles => :web do
run "cd #{current_path} && touch maintenance.flag"
end
desc <<-DESC
Enable the Magento stores by removing the maintenance.flag in the web root.
DESC
task :enable, :roles => :web do
run "cd #{current_path} && rm -f maintenance.flag"
end
end
after 'deploy:setup', 'mage:setup'
after 'deploy:finalize_update', 'mage:finalize_update'