capistrano-exts 1.11.3 → 1.12.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (40) hide show
  1. data/.todo +9 -0
  2. data/README.md +3 -3
  3. data/TODO +3 -0
  4. data/examples/php_fpm/deploy/development.rb +16 -0
  5. data/examples/php_fpm/deploy/production.rb +16 -0
  6. data/examples/php_fpm/deploy/staging.rb +16 -0
  7. data/examples/rails_passenger/deploy/development.rb +16 -0
  8. data/examples/rails_passenger/deploy/production.rb +16 -0
  9. data/examples/rails_passenger/deploy/staging.rb +16 -0
  10. data/examples/rails_reverse_proxy/deploy/development.rb +16 -0
  11. data/examples/rails_reverse_proxy/deploy/production.rb +16 -0
  12. data/examples/rails_reverse_proxy/deploy/staging.rb +16 -0
  13. data/lib/capistrano-exts.rb +1 -1
  14. data/lib/capistrano-exts/receipts.rb +10 -1
  15. data/lib/capistrano-exts/receipts/contao.rb +1 -5
  16. data/lib/capistrano-exts/receipts/contents.rb +2 -6
  17. data/lib/capistrano-exts/receipts/deploy.rb +5 -9
  18. data/lib/capistrano-exts/receipts/files.rb +0 -4
  19. data/lib/capistrano-exts/receipts/functions.rb +1 -4
  20. data/lib/capistrano-exts/receipts/git.rb +0 -2
  21. data/lib/capistrano-exts/receipts/god.rb +0 -2
  22. data/lib/capistrano-exts/receipts/multistage.rb +0 -2
  23. data/lib/capistrano-exts/receipts/mysql.rb +5 -10
  24. data/lib/capistrano-exts/receipts/rails.rb +0 -4
  25. data/lib/capistrano-exts/receipts/servers.rb +1 -3
  26. data/lib/capistrano-exts/receipts/servers/web_server.rb +1 -1
  27. data/lib/capistrano-exts/receipts/unicorn.rb +28 -21
  28. data/lib/capistrano-exts/receipts/web.rb +136 -0
  29. data/lib/capistrano-exts/servers/web_server.rb +5 -5
  30. data/lib/capistrano-exts/templates/maintenance/index.rhtml +26 -0
  31. data/lib/capistrano-exts/templates/maintenance/stylesheets/styles.css +37 -0
  32. data/lib/capistrano-exts/templates/multistage.rb +16 -0
  33. data/lib/capistrano-exts/templates/web_servers/nginx.conf.erb +25 -11
  34. data/lib/capistrano-exts/version.rb +2 -2
  35. data/spec/{requests → acceptance}/nginx_spec.rb +28 -8
  36. data/spec/rendered_templates/nginx_passenger.conf +24 -10
  37. data/spec/rendered_templates/nginx_php_fpm.conf +25 -6
  38. data/spec/rendered_templates/nginx_reverse_proxy_address.conf +25 -6
  39. data/spec/rendered_templates/nginx_reverse_proxy_socket.conf +25 -6
  40. metadata +23 -20
data/.todo CHANGED
@@ -1,5 +1,11 @@
1
1
  <?xml version="1.0"?>
2
2
  <todo version="0.1.20">
3
+ <note priority="veryhigh" time="1316597225" done="1316600338">
4
+ Rename deploy:folders to deploy:setup:folders
5
+ <comment>
6
+ Can't be done, setup is a task
7
+ </comment>
8
+ </note>
3
9
  <note priority="high" time="1316510985">
4
10
  Add skip_table_on_sync configuration, if defined, we should not replace these tables on the target's database.
5
11
  </note>
@@ -12,4 +18,7 @@
12
18
  <note priority="medium" time="1316510880">
13
19
  Add tests using Vagrant (branch vagrant)
14
20
  </note>
21
+ <note priority="medium" time="1316594507">
22
+ In the nginx template file, we need to define the error pages dynamically and not in a hardcoded way.
23
+ </note>
15
24
  </todo>
data/README.md CHANGED
@@ -18,7 +18,7 @@ gem install capistrano-exts
18
18
  or add it to your Gemfile
19
19
 
20
20
  ```ruby
21
- gem 'capistrano-exts', '>=1.11.3', :require => false
21
+ gem 'capistrano-exts', '>=1.12.0', :require => false
22
22
  ```
23
23
 
24
24
  # Setup
@@ -39,8 +39,8 @@ set :stages, [:development, :staging, :production]
39
39
  set :default_stage, :development
40
40
 
41
41
  # Capistrano extensions
42
- # Valid extensions: :multistage, :git, :deploy, :mysql, :rails, :contao, :contents, :god, :unicorn, :servers
43
- set :capistrano_extensions, [:multistage, :git, :deploy, :mysql, :rails, :servers]
42
+ # Valid extensions: :multistage, :git, :mysql, :rails, :contao, :contents, :god, :unicorn, :servers
43
+ set :capistrano_extensions, [:multistage, :git, :mysql, :rails, :servers]
44
44
  ```
45
45
 
46
46
  Then run the command
data/TODO CHANGED
@@ -9,3 +9,6 @@
9
9
 
10
10
  - Add tests using Vagrant (branch vagrant)
11
11
  (added Tue Sep 20 11:28:00 2011, incomplete, priority medium)
12
+
13
+ - In the nginx template file, we need to define the error pages dynamically and not in a hardcoded way.
14
+ (added Wed Sep 21 10:41:47 2011, incomplete, priority medium)
@@ -89,6 +89,22 @@ set :shared_items, [
89
89
  #
90
90
  #############
91
91
 
92
+ #############
93
+ # Maintenance
94
+ #
95
+
96
+ # Set the maintenance path to wherever you have stored the maintenance page,
97
+ # it could be a single file or an entire folder. The template will be parsed
98
+ # with ERB.
99
+ # if it's a folder, capistrano expects an index.html file. You could provide an
100
+ # index.rhtml file and it would be parsed with ERB before uploading to the server
101
+ # set :maintenance_path,
102
+ # File.expand_path(File.join(File.dirname(__FILE__), '..', '..', 'maintenance'))
103
+
104
+ #
105
+ #
106
+ #############
107
+
92
108
  #############
93
109
  # Mysql
94
110
  #
@@ -89,6 +89,22 @@ set :shared_items, [
89
89
  #
90
90
  #############
91
91
 
92
+ #############
93
+ # Maintenance
94
+ #
95
+
96
+ # Set the maintenance path to wherever you have stored the maintenance page,
97
+ # it could be a single file or an entire folder. The template will be parsed
98
+ # with ERB.
99
+ # if it's a folder, capistrano expects an index.html file. You could provide an
100
+ # index.rhtml file and it would be parsed with ERB before uploading to the server
101
+ # set :maintenance_path,
102
+ # File.expand_path(File.join(File.dirname(__FILE__), '..', '..', 'maintenance'))
103
+
104
+ #
105
+ #
106
+ #############
107
+
92
108
  #############
93
109
  # Mysql
94
110
  #
@@ -89,6 +89,22 @@ set :shared_items, [
89
89
  #
90
90
  #############
91
91
 
92
+ #############
93
+ # Maintenance
94
+ #
95
+
96
+ # Set the maintenance path to wherever you have stored the maintenance page,
97
+ # it could be a single file or an entire folder. The template will be parsed
98
+ # with ERB.
99
+ # if it's a folder, capistrano expects an index.html file. You could provide an
100
+ # index.rhtml file and it would be parsed with ERB before uploading to the server
101
+ # set :maintenance_path,
102
+ # File.expand_path(File.join(File.dirname(__FILE__), '..', '..', 'maintenance'))
103
+
104
+ #
105
+ #
106
+ #############
107
+
92
108
  #############
93
109
  # Mysql
94
110
  #
@@ -91,6 +91,22 @@ set :configuration_files, [
91
91
  #
92
92
  #############
93
93
 
94
+ #############
95
+ # Maintenance
96
+ #
97
+
98
+ # Set the maintenance path to wherever you have stored the maintenance page,
99
+ # it could be a single file or an entire folder. The template will be parsed
100
+ # with ERB.
101
+ # if it's a folder, capistrano expects an index.html file. You could provide an
102
+ # index.rhtml file and it would be parsed with ERB before uploading to the server
103
+ # set :maintenance_path,
104
+ # File.expand_path(File.join(File.dirname(__FILE__), '..', '..', 'maintenance'))
105
+
106
+ #
107
+ #
108
+ #############
109
+
94
110
  #############
95
111
  # Mysql
96
112
  #
@@ -91,6 +91,22 @@ set :configuration_files, [
91
91
  #
92
92
  #############
93
93
 
94
+ #############
95
+ # Maintenance
96
+ #
97
+
98
+ # Set the maintenance path to wherever you have stored the maintenance page,
99
+ # it could be a single file or an entire folder. The template will be parsed
100
+ # with ERB.
101
+ # if it's a folder, capistrano expects an index.html file. You could provide an
102
+ # index.rhtml file and it would be parsed with ERB before uploading to the server
103
+ # set :maintenance_path,
104
+ # File.expand_path(File.join(File.dirname(__FILE__), '..', '..', 'maintenance'))
105
+
106
+ #
107
+ #
108
+ #############
109
+
94
110
  #############
95
111
  # Mysql
96
112
  #
@@ -91,6 +91,22 @@ set :configuration_files, [
91
91
  #
92
92
  #############
93
93
 
94
+ #############
95
+ # Maintenance
96
+ #
97
+
98
+ # Set the maintenance path to wherever you have stored the maintenance page,
99
+ # it could be a single file or an entire folder. The template will be parsed
100
+ # with ERB.
101
+ # if it's a folder, capistrano expects an index.html file. You could provide an
102
+ # index.rhtml file and it would be parsed with ERB before uploading to the server
103
+ # set :maintenance_path,
104
+ # File.expand_path(File.join(File.dirname(__FILE__), '..', '..', 'maintenance'))
105
+
106
+ #
107
+ #
108
+ #############
109
+
94
110
  #############
95
111
  # Mysql
96
112
  #
@@ -91,6 +91,22 @@ set :configuration_files, [
91
91
  #
92
92
  #############
93
93
 
94
+ #############
95
+ # Maintenance
96
+ #
97
+
98
+ # Set the maintenance path to wherever you have stored the maintenance page,
99
+ # it could be a single file or an entire folder. The template will be parsed
100
+ # with ERB.
101
+ # if it's a folder, capistrano expects an index.html file. You could provide an
102
+ # index.rhtml file and it would be parsed with ERB before uploading to the server
103
+ # set :maintenance_path,
104
+ # File.expand_path(File.join(File.dirname(__FILE__), '..', '..', 'maintenance'))
105
+
106
+ #
107
+ #
108
+ #############
109
+
94
110
  #############
95
111
  # Mysql
96
112
  #
@@ -91,6 +91,22 @@ set :configuration_files, [
91
91
  #
92
92
  #############
93
93
 
94
+ #############
95
+ # Maintenance
96
+ #
97
+
98
+ # Set the maintenance path to wherever you have stored the maintenance page,
99
+ # it could be a single file or an entire folder. The template will be parsed
100
+ # with ERB.
101
+ # if it's a folder, capistrano expects an index.html file. You could provide an
102
+ # index.rhtml file and it would be parsed with ERB before uploading to the server
103
+ # set :maintenance_path,
104
+ # File.expand_path(File.join(File.dirname(__FILE__), '..', '..', 'maintenance'))
105
+
106
+ #
107
+ #
108
+ #############
109
+
94
110
  #############
95
111
  # Mysql
96
112
  #
@@ -91,6 +91,22 @@ set :configuration_files, [
91
91
  #
92
92
  #############
93
93
 
94
+ #############
95
+ # Maintenance
96
+ #
97
+
98
+ # Set the maintenance path to wherever you have stored the maintenance page,
99
+ # it could be a single file or an entire folder. The template will be parsed
100
+ # with ERB.
101
+ # if it's a folder, capistrano expects an index.html file. You could provide an
102
+ # index.rhtml file and it would be parsed with ERB before uploading to the server
103
+ # set :maintenance_path,
104
+ # File.expand_path(File.join(File.dirname(__FILE__), '..', '..', 'maintenance'))
105
+
106
+ #
107
+ #
108
+ #############
109
+
94
110
  #############
95
111
  # Mysql
96
112
  #
@@ -2,7 +2,7 @@
2
2
 
3
3
  # Add it to PATH
4
4
  ROOT_PATH = File.expand_path(File.dirname(__FILE__))
5
- $: << ROOT_PATH if File.directory?(ROOT_PATH) && !$:.include?(ROOT_PATH)
5
+ $: << ROOT_PATH if File.directory?(ROOT_PATH) and not $:.include?(ROOT_PATH)
6
6
 
7
7
  # Require our core extensions
8
8
  require 'capistrano-exts/core_ext'
@@ -1,14 +1,23 @@
1
1
  require 'capistrano'
2
- require 'capistrano-exts/receipts/functions'
2
+ require 'capistrano/errors'
3
+ require 'erb'
4
+
3
5
 
4
6
  # Verify that Capistrano is version 2
5
7
  unless Capistrano::Configuration.respond_to?(:instance)
6
8
  abort "This extension requires Capistrano 2"
7
9
  end
8
10
 
11
+ DEFAULT_RECEIPTS = %w{functions deploy web files}
12
+
9
13
  Capistrano::Configuration.instance(:must_exist).load do
10
14
  on :load do
11
15
  if exists?(:capistrano_extensions)
16
+ # Merge the requested receipts with the default receipts
17
+ capistrano_extensions = fetch(:capistrano_extensions) << DEFAULT_RECEIPTS
18
+ capistrano_extensions.flatten!.uniq!
19
+
20
+ # Require requested + default receipts
12
21
  capistrano_extensions.each do |receipt|
13
22
  require "capistrano-exts/receipts/#{receipt.to_s}"
14
23
  end
@@ -1,7 +1,3 @@
1
- require 'capistrano'
2
- require 'capistrano/errors'
3
- require 'capistrano-exts/receipts/functions'
4
- require 'capistrano-exts/receipts/deploy'
5
1
  require 'capistrano-exts/receipts/mysql'
6
2
 
7
3
  # Verify that Capistrano is version 2
@@ -38,7 +34,7 @@ Capistrano::Configuration.instance(:must_exist).load do
38
34
 
39
35
  desc "[internal] Setup contao's localconfig"
40
36
  task :setup_localconfig, :roles => :app, :except => { :no_release => true } do
41
- localconfig_php_config_path = "#{fetch :shared_path}/config/system_config_localconfig.php"
37
+ localconfig_php_config_path = "#{fetch :shared_path}/config/public_system_config_localconfig.php"
42
38
  unless remote_file_exists?(localconfig_php_config_path)
43
39
  on_rollback { run "rm -f #{localconfig_php_config_path}" }
44
40
 
@@ -1,7 +1,3 @@
1
- require 'capistrano'
2
- require 'capistrano/errors'
3
- require 'capistrano-exts/receipts/functions'
4
-
5
1
  # Verify that Capistrano is version 2
6
2
  unless Capistrano::Configuration.respond_to?(:instance)
7
3
  abort "This extension requires Capistrano 2"
@@ -83,7 +79,7 @@ Capistrano::Configuration.instance(:must_exist).load do
83
79
  export_filename_argv = ARGV.try(:[], argv_file_index)
84
80
 
85
81
  # Generate the file name
86
- if export_filename_argv && !export_filename_argv =~ /.+:.+/ && !File.exists?(export_filename_argv)
82
+ if export_filename_argv and not export_filename_argv =~ /.+:.+/ and not File.exists?(export_filename_argv)
87
83
  export_filename = export_filename_argv
88
84
  else
89
85
  export_filename = random_tmp_file + ".tar.gz"
@@ -101,7 +97,7 @@ Capistrano::Configuration.instance(:must_exist).load do
101
97
  # Find out at which index the file is located ?
102
98
  argv_file_index = ARGV.index("contents:import") + 1
103
99
 
104
- unless ARGV.size >= (argv_file_index + 1) && File.exists?(ARGV[argv_file_index])
100
+ unless ARGV.size >= (argv_file_index + 1) and File.exists?(ARGV[argv_file_index])
105
101
  logger.important "ERROR: please run 'cap import <gzipped tar>'"
106
102
  exit 1
107
103
  else
@@ -1,8 +1,3 @@
1
- require 'capistrano'
2
- require 'capistrano/errors'
3
- require 'capistrano-exts/receipts/functions'
4
- require 'capistrano-exts/receipts/files'
5
-
6
1
  # Verify that Capistrano is version 2
7
2
  unless Capistrano::Configuration.respond_to?(:instance)
8
3
  abort "This extension requires Capistrano 2"
@@ -38,14 +33,15 @@ Capistrano::Configuration.instance(:must_exist).load do
38
33
  backup_path = fetch :backup_path, "#{fetch :deploy_to}/backups"
39
34
 
40
35
  run <<-CMD
41
- mkdir -p #{fetch :deploy_to} &&
42
- mkdir -p #{backup_path} &&
43
- mkdir -p #{fetch :shared_path}/items
36
+ #{try_sudo} mkdir -p #{fetch :deploy_to} &&
37
+ #{try_sudo} mkdir -p #{backup_path} &&
38
+ #{try_sudo} mkdir -p #{fetch :shared_path}/items &&
39
+ #{try_sudo} mkdir -p #{shared_path}/__system__
44
40
  CMD
45
41
 
46
42
  if exists? :logs_path
47
43
  run <<-CMD
48
- mkdir -p #{fetch :logs_path}
44
+ #{try_sudo} mkdir -p #{fetch :logs_path}
49
45
  CMD
50
46
  end
51
47
  end
@@ -1,7 +1,3 @@
1
- require 'capistrano'
2
- require 'capistrano/errors'
3
- require 'capistrano-exts/receipts/functions'
4
-
5
1
  # Verify that Capistrano is version 2
6
2
  unless Capistrano::Configuration.respond_to?(:instance)
7
3
  abort "This extension requires Capistrano 2"
@@ -1,4 +1,3 @@
1
- require 'capistrano'
2
1
  require 'digest/sha1'
3
2
  require 'highline'
4
3
 
@@ -15,8 +14,6 @@ Capistrano::Configuration.instance(:must_exist).load do
15
14
  end
16
15
 
17
16
  def link_file(source_file, destination_file)
18
- p source_file
19
- p destination_file
20
17
  if remote_file_exists?(source_file)
21
18
  begin
22
19
  run "#{try_sudo} ln -nsf #{source_file} #{destination_file}"
@@ -133,7 +130,7 @@ password: #{credentials[:pass]}
133
130
  # This function asks the user for confirmation (confirm running the task)
134
131
  # If the user answers no, then the task won't be executed.
135
132
  def ask_for_confirmation(what, options = {})
136
- unless exists?(:force) && fetch(:force) == true
133
+ unless exists?(:force) and fetch(:force) == true
137
134
  # Ask for a confirmation
138
135
  response = ask(what, options)
139
136
  if response =~ /(no?)|(a(bort)?|\n)/i
@@ -1,6 +1,4 @@
1
- require 'capistrano'
2
1
  require 'highline'
3
- require 'capistrano-exts/receipts/deploy'
4
2
 
5
3
  # Verify that Capistrano is version 2
6
4
  unless Capistrano::Configuration.respond_to?(:instance)
@@ -1,5 +1,3 @@
1
- require 'capistrano'
2
-
3
1
  # Verify that Capistrano is version 2
4
2
  unless Capistrano::Configuration.respond_to?(:instance)
5
3
  abort "This extension requires Capistrano 2"
@@ -2,8 +2,6 @@
2
2
  # https://github.com/capistrano/capistrano-ext and has been modified
3
3
  # To allow configuration in either seperate files or in-line configurations
4
4
 
5
- require 'capistrano'
6
- require 'capistrano-exts/receipts/functions'
7
5
  require 'fileutils'
8
6
 
9
7
  unless Capistrano::Configuration.respond_to?(:instance)
@@ -1,8 +1,3 @@
1
- require 'capistrano'
2
- require 'capistrano/errors'
3
- require 'capistrano-exts/receipts/functions'
4
- require 'capistrano-exts/receipts/deploy'
5
-
6
1
  # Verify that Capistrano is version 2
7
2
  unless Capistrano::Configuration.respond_to?(:instance)
8
3
  abort "This extension requires Capistrano 2"
@@ -160,7 +155,7 @@ Capistrano::Configuration.instance(:must_exist).load do
160
155
  # Find out at which index the file is located ?
161
156
  argv_file_index = ARGV.index("mysql:import_db_dump") + 1
162
157
 
163
- unless ARGV.size >= (argv_file_index + 1) && File.exists?(ARGV[argv_file_index])
158
+ unless ARGV.size >= (argv_file_index + 1) and File.exists?(ARGV[argv_file_index])
164
159
  logger.important "ERROR: please run 'cap mysql:import_db_dump <sql dump>'"
165
160
  exit 1
166
161
  else
@@ -229,7 +224,7 @@ Capistrano::Configuration.instance(:must_exist).load do
229
224
  export_filename_argv = ARGV.try(:[], argv_file_index)
230
225
 
231
226
  # Generate the file name
232
- if export_filename_argv && !export_filename_argv =~ /.+:.+/ && !File.exists?(export_filename_argv)
227
+ if export_filename_argv and not export_filename_argv =~ /.+:.+/ and not File.exists?(export_filename_argv)
233
228
  export_filename = export_filename_argv
234
229
  else
235
230
  export_filename = random_tmp_file + ".sql"
@@ -320,7 +315,7 @@ Capistrano::Configuration.instance(:must_exist).load do
320
315
 
321
316
  desc "[internal] write database #{var.gsub(/_/, ' ')}"
322
317
  task "write_#{var}" do
323
- unless exists?("mysql_#{var}_file".to_sym) && remote_file_exists?(fetch "mysql_#{var}_file".to_sym)
318
+ unless exists?("mysql_#{var}_file".to_sym) and remote_file_exists?(fetch "mysql_#{var}_file".to_sym)
324
319
  mysql_credentials_file = fetch "mysql_#{var}_file".to_sym
325
320
  credentials_formatted_content = credentials_formatted(fetch "mysql_#{var}".to_sym)
326
321
  random_file = random_tmp_file(credentials_formatted_content)
@@ -355,7 +350,7 @@ Capistrano::Configuration.instance(:must_exist).load do
355
350
  mysql_credentials_pass_regex_match = fetch "mysql_#{var}_pass_regex_match".to_sym
356
351
 
357
352
  # We haven't got the credentials yet, look for them
358
- if exists?("mysql_#{var}_file".to_sym) && remote_file_exists?(fetch "mysql_#{var}_file".to_sym)
353
+ if exists?("mysql_#{var}_file".to_sym) and remote_file_exists?(fetch "mysql_#{var}_file".to_sym)
359
354
  mysql_credentials_file = fetch "mysql_#{var}_file".to_sym
360
355
 
361
356
  begin
@@ -395,7 +390,7 @@ Capistrano::Configuration.instance(:must_exist).load do
395
390
  end
396
391
 
397
392
  # Finally set it so it's available and write it to the server.
398
- if mysql_credentials[:user].present? && mysql_credentials[:pass].present?
393
+ if mysql_credentials[:user].present? and mysql_credentials[:pass].present?
399
394
  set "mysql_#{var}".to_sym, mysql_credentials
400
395
  find_and_execute_task("mysql:write_#{var}")
401
396
  end