capistrano-exts 1.0.0 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.travis.yml +7 -0
- data/Gemfile +1 -1
- data/MIT-LICENSE +20 -0
- data/README.md +72 -0
- data/capistrano-exts.gemspec +8 -4
- data/examples/php_fpm/deploy/development.rb +2 -2
- data/examples/php_fpm/deploy/production.rb +2 -2
- data/examples/php_fpm/deploy/staging.rb +2 -2
- data/examples/php_fpm/deploy.rb +1 -1
- data/examples/rails_passenger/deploy/development.rb +3 -3
- data/examples/rails_passenger/deploy/production.rb +3 -3
- data/examples/rails_passenger/deploy/staging.rb +3 -3
- data/examples/rails_passenger/deploy.rb +1 -1
- data/examples/rails_reverse_proxy/deploy/development.rb +2 -2
- data/examples/rails_reverse_proxy/deploy/production.rb +2 -2
- data/examples/rails_reverse_proxy/deploy/staging.rb +2 -2
- data/examples/rails_reverse_proxy/deploy.rb +1 -1
- data/lib/capistrano-exts/receipts/contao.rb +2 -9
- data/lib/capistrano-exts/receipts/{base.rb → deploy.rb} +14 -0
- data/lib/capistrano-exts/receipts/git.rb +1 -1
- data/lib/capistrano-exts/receipts/mysql.rb +1 -1
- data/lib/capistrano-exts/receipts/rails.rb +9 -12
- data/lib/capistrano-exts/receipts/servers/web_server/apache.rb +2 -2
- data/lib/capistrano-exts/receipts/servers/web_server/nginx.rb +2 -2
- data/lib/capistrano-exts/receipts/servers.rb +1 -1
- data/lib/capistrano-exts/servers/web_server/nginx.rb +1 -1
- data/lib/capistrano-exts/servers/web_server.rb +26 -2
- data/lib/capistrano-exts/templates/multistage.rb +6 -2
- data/lib/capistrano-exts/templates/web_servers/nginx.conf.erb +1 -1
- data/lib/capistrano-exts/version.rb +1 -1
- data/spec/requests/nginx_spec.rb +1 -1
- data/spec/servers/web_server/nginx_spec.rb +98 -21
- metadata +41 -51
data/.travis.yml
ADDED
data/Gemfile
CHANGED
data/MIT-LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2011 Wael Nasreddine <wael.nasreddine@gmail.com>
|
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.md
ADDED
@@ -0,0 +1,72 @@
|
|
1
|
+
Capistrano Extensions [![Build Status](http://travis-ci.org/TechnoGate/capistrano-exts.png)](http://travis-ci.org/TechnoGate/capistrano-exts)
|
2
|
+
=====
|
3
|
+
This gem provides some useful capistrano tasks, for preparing the server,
|
4
|
+
the database and the application without ever SSH'ing to the destination server,
|
5
|
+
it also provides multistage functionality just like [capistano-ext](https://github.com/capistrano/capistrano-ext)
|
6
|
+
gem, in fact the included multistage file is a modified version of capistrano-ext
|
7
|
+
|
8
|
+
Installation
|
9
|
+
------------
|
10
|
+
|
11
|
+
Install the gem
|
12
|
+
|
13
|
+
```ruby
|
14
|
+
gem install capistrano-ext
|
15
|
+
```
|
16
|
+
|
17
|
+
or add it to your Gemfile
|
18
|
+
|
19
|
+
```ruby
|
20
|
+
gem 'capistrano-ext', '>=1.0.0'
|
21
|
+
```
|
22
|
+
|
23
|
+
Setup
|
24
|
+
-----
|
25
|
+
First make sure you have capified your project, if not then run the following command on the root of your project:
|
26
|
+
|
27
|
+
```bash
|
28
|
+
$ capify .
|
29
|
+
```
|
30
|
+
|
31
|
+
Then open up __config/deploy.rb__ and add the following to the top of the file
|
32
|
+
|
33
|
+
```ruby
|
34
|
+
# Stages
|
35
|
+
# Stages can be really anything you want
|
36
|
+
set :stages, [:development, :staging, :production]
|
37
|
+
set :default_stage, :development
|
38
|
+
|
39
|
+
# Capistrano extensions
|
40
|
+
# Valid extensions: :multistage, :git, :deploy, :mysql, :rails, :contao, :god, :unicorn, :servers
|
41
|
+
set :capistrano_extensions, [:multistage, :git, :deploy, :mysql, :rails, :servers]
|
42
|
+
```
|
43
|
+
|
44
|
+
Then run the command
|
45
|
+
|
46
|
+
```bash
|
47
|
+
$ cap multistage:prepare
|
48
|
+
```
|
49
|
+
|
50
|
+
Then edit the files found at __config/deploy/*.rb__, that's it you're ready..
|
51
|
+
|
52
|
+
Usage
|
53
|
+
-----
|
54
|
+
|
55
|
+
The server can be prepared by running:
|
56
|
+
|
57
|
+
```bash
|
58
|
+
$ cap deploy:server:prepare deploy:setup
|
59
|
+
```
|
60
|
+
|
61
|
+
Deploy with
|
62
|
+
|
63
|
+
```bash
|
64
|
+
$ cap deploy
|
65
|
+
```
|
66
|
+
|
67
|
+
That's pretty much it
|
68
|
+
|
69
|
+
|
70
|
+
License
|
71
|
+
-------
|
72
|
+
This code is free to use under the terms of the MIT license.
|
data/capistrano-exts.gemspec
CHANGED
@@ -24,12 +24,16 @@ Gem::Specification.new do |s|
|
|
24
24
|
s.add_dependency('activesupport', '>=3.1.0')
|
25
25
|
|
26
26
|
# Development dependencies
|
27
|
+
s.add_development_dependency('guard', '>=0.6.2')
|
28
|
+
s.add_development_dependency('guard-bundler', '>=0.1.3')
|
29
|
+
s.add_development_dependency('guard-rspec', '>=0.4.3')
|
30
|
+
|
31
|
+
# Install this gem manually to get growl notifications on Mac OS X
|
32
|
+
# s.add_development_dependency('growl_notify', '0.0.1')
|
33
|
+
|
34
|
+
# Development / Test dependencies
|
27
35
|
s.add_development_dependency('rspec', '>=2.6.0')
|
28
36
|
s.add_development_dependency('mocha', '>=0.2.12')
|
29
37
|
s.add_development_dependency('factory_girl', '>=2.0.5')
|
30
38
|
s.add_development_dependency('faker19', '>=1.0.5')
|
31
|
-
s.add_development_dependency('guard', '>=0.6.2')
|
32
|
-
s.add_development_dependency('guard-bundler', '>=0.1.3')
|
33
|
-
s.add_development_dependency('guard-rspec', '>=0.4.3')
|
34
|
-
s.add_development_dependency('growl_notify', '0.0.1')
|
35
39
|
end
|
@@ -92,9 +92,9 @@ set :web_server_mod_rewrite, true
|
|
92
92
|
# Valid options:
|
93
93
|
#
|
94
94
|
# For Nginx:
|
95
|
-
# => :rails_reverse_proxy, :
|
95
|
+
# => :rails_reverse_proxy, :passenger, :php_fpm
|
96
96
|
# => :rails_reverse_proxy is used for unicorn (Rack apps)
|
97
|
-
# => :
|
97
|
+
# => :passenger runs rails apps
|
98
98
|
# => :php_fpm is used to deliver websites written using PHP
|
99
99
|
#
|
100
100
|
# For Apache
|
@@ -92,9 +92,9 @@ set :web_server_mod_rewrite, true
|
|
92
92
|
# Valid options:
|
93
93
|
#
|
94
94
|
# For Nginx:
|
95
|
-
# => :rails_reverse_proxy, :
|
95
|
+
# => :rails_reverse_proxy, :passenger, :php_fpm
|
96
96
|
# => :rails_reverse_proxy is used for unicorn (Rack apps)
|
97
|
-
# => :
|
97
|
+
# => :passenger runs rails apps
|
98
98
|
# => :php_fpm is used to deliver websites written using PHP
|
99
99
|
#
|
100
100
|
# For Apache
|
@@ -92,9 +92,9 @@ set :web_server_mod_rewrite, true
|
|
92
92
|
# Valid options:
|
93
93
|
#
|
94
94
|
# For Nginx:
|
95
|
-
# => :rails_reverse_proxy, :
|
95
|
+
# => :rails_reverse_proxy, :passenger, :php_fpm
|
96
96
|
# => :rails_reverse_proxy is used for unicorn (Rack apps)
|
97
|
-
# => :
|
97
|
+
# => :passenger runs rails apps
|
98
98
|
# => :php_fpm is used to deliver websites written using PHP
|
99
99
|
#
|
100
100
|
# For Apache
|
data/examples/php_fpm/deploy.rb
CHANGED
@@ -15,7 +15,7 @@ set :stages, [:development, :staging, :production]
|
|
15
15
|
set :default_stage, :development
|
16
16
|
|
17
17
|
# Capistrano extensions
|
18
|
-
set :capistrano_extensions, [:multistage, :git, :
|
18
|
+
set :capistrano_extensions, [:multistage, :git, :deploy, :mysql, :contao, :servers]
|
19
19
|
|
20
20
|
default_run_options[:pty] = true
|
21
21
|
ssh_options[:forward_agent] = true
|
@@ -92,14 +92,14 @@ set :web_server_mod_rewrite, true
|
|
92
92
|
# Valid options:
|
93
93
|
#
|
94
94
|
# For Nginx:
|
95
|
-
# => :rails_reverse_proxy, :
|
95
|
+
# => :rails_reverse_proxy, :passenger, :php_fpm
|
96
96
|
# => :rails_reverse_proxy is used for unicorn (Rack apps)
|
97
|
-
# => :
|
97
|
+
# => :passenger runs rails apps
|
98
98
|
# => :php_fpm is used to deliver websites written using PHP
|
99
99
|
#
|
100
100
|
# For Apache
|
101
101
|
# =>
|
102
|
-
set :web_server_mode, :
|
102
|
+
set :web_server_mode, :passenger
|
103
103
|
|
104
104
|
# Server mode specific configurations
|
105
105
|
# Uncomment and edit the one depending on the enabled mode
|
@@ -92,14 +92,14 @@ set :web_server_mod_rewrite, true
|
|
92
92
|
# Valid options:
|
93
93
|
#
|
94
94
|
# For Nginx:
|
95
|
-
# => :rails_reverse_proxy, :
|
95
|
+
# => :rails_reverse_proxy, :passenger, :php_fpm
|
96
96
|
# => :rails_reverse_proxy is used for unicorn (Rack apps)
|
97
|
-
# => :
|
97
|
+
# => :passenger runs rails apps
|
98
98
|
# => :php_fpm is used to deliver websites written using PHP
|
99
99
|
#
|
100
100
|
# For Apache
|
101
101
|
# =>
|
102
|
-
set :web_server_mode, :
|
102
|
+
set :web_server_mode, :passenger
|
103
103
|
|
104
104
|
# Server mode specific configurations
|
105
105
|
# Uncomment and edit the one depending on the enabled mode
|
@@ -92,14 +92,14 @@ set :web_server_mod_rewrite, true
|
|
92
92
|
# Valid options:
|
93
93
|
#
|
94
94
|
# For Nginx:
|
95
|
-
# => :rails_reverse_proxy, :
|
95
|
+
# => :rails_reverse_proxy, :passenger, :php_fpm
|
96
96
|
# => :rails_reverse_proxy is used for unicorn (Rack apps)
|
97
|
-
# => :
|
97
|
+
# => :passenger runs rails apps
|
98
98
|
# => :php_fpm is used to deliver websites written using PHP
|
99
99
|
#
|
100
100
|
# For Apache
|
101
101
|
# =>
|
102
|
-
set :web_server_mode, :
|
102
|
+
set :web_server_mode, :passenger
|
103
103
|
|
104
104
|
# Server mode specific configurations
|
105
105
|
# Uncomment and edit the one depending on the enabled mode
|
@@ -15,7 +15,7 @@ set :stages, [:development, :staging, :production]
|
|
15
15
|
set :default_stage, :development
|
16
16
|
|
17
17
|
# Capistrano extensions
|
18
|
-
set :capistrano_extensions, [:multistage, :git, :
|
18
|
+
set :capistrano_extensions, [:multistage, :git, :deploy, :mysql, :rails, :servers]
|
19
19
|
|
20
20
|
default_run_options[:pty] = true
|
21
21
|
ssh_options[:forward_agent] = true
|
@@ -92,9 +92,9 @@ set :web_server_mod_rewrite, true
|
|
92
92
|
# Valid options:
|
93
93
|
#
|
94
94
|
# For Nginx:
|
95
|
-
# => :rails_reverse_proxy, :
|
95
|
+
# => :rails_reverse_proxy, :passenger, :php_fpm
|
96
96
|
# => :rails_reverse_proxy is used for unicorn (Rack apps)
|
97
|
-
# => :
|
97
|
+
# => :passenger runs rails apps
|
98
98
|
# => :php_fpm is used to deliver websites written using PHP
|
99
99
|
#
|
100
100
|
# For Apache
|
@@ -92,9 +92,9 @@ set :web_server_mod_rewrite, true
|
|
92
92
|
# Valid options:
|
93
93
|
#
|
94
94
|
# For Nginx:
|
95
|
-
# => :rails_reverse_proxy, :
|
95
|
+
# => :rails_reverse_proxy, :passenger, :php_fpm
|
96
96
|
# => :rails_reverse_proxy is used for unicorn (Rack apps)
|
97
|
-
# => :
|
97
|
+
# => :passenger runs rails apps
|
98
98
|
# => :php_fpm is used to deliver websites written using PHP
|
99
99
|
#
|
100
100
|
# For Apache
|
@@ -92,9 +92,9 @@ set :web_server_mod_rewrite, true
|
|
92
92
|
# Valid options:
|
93
93
|
#
|
94
94
|
# For Nginx:
|
95
|
-
# => :rails_reverse_proxy, :
|
95
|
+
# => :rails_reverse_proxy, :passenger, :php_fpm
|
96
96
|
# => :rails_reverse_proxy is used for unicorn (Rack apps)
|
97
|
-
# => :
|
97
|
+
# => :passenger runs rails apps
|
98
98
|
# => :php_fpm is used to deliver websites written using PHP
|
99
99
|
#
|
100
100
|
# For Apache
|
@@ -15,7 +15,7 @@ set :stages, [:development, :staging, :production]
|
|
15
15
|
set :default_stage, :development
|
16
16
|
|
17
17
|
# Capistrano extensions
|
18
|
-
set :capistrano_extensions, [:multistage, :git, :
|
18
|
+
set :capistrano_extensions, [:multistage, :git, :deploy, :mysql, :rails, :servers]
|
19
19
|
|
20
20
|
default_run_options[:pty] = true
|
21
21
|
ssh_options[:forward_agent] = true
|
@@ -1,5 +1,5 @@
|
|
1
1
|
require 'capistrano'
|
2
|
-
require 'capistrano-exts/receipts/
|
2
|
+
require 'capistrano-exts/receipts/deploy'
|
3
3
|
require 'capistrano-exts/receipts/mysql'
|
4
4
|
|
5
5
|
# Verify that Capistrano is version 2
|
@@ -58,13 +58,6 @@ Capistrano::Configuration.instance(:must_exist).load do
|
|
58
58
|
#{try_sudo} ln -nsf #{fetch :shared_path}/log #{fetch :latest_release}/log
|
59
59
|
CMD
|
60
60
|
end
|
61
|
-
|
62
|
-
task :fix_permissions, :roles => :app, :except => { :no_release => true } do
|
63
|
-
run <<-CMD
|
64
|
-
#{try_sudo} chown -R www-data:www-data #{deploy_to} &&
|
65
|
-
#{try_sudo} chmod -R g+w #{latest_release}
|
66
|
-
CMD
|
67
|
-
end
|
68
61
|
end
|
69
62
|
|
70
63
|
# Dependencies
|
@@ -73,7 +66,7 @@ Capistrano::Configuration.instance(:must_exist).load do
|
|
73
66
|
after "contao:setup_localconfig", "mysql:create_db"
|
74
67
|
after "deploy:finalize_update", "contao:fix_links"
|
75
68
|
after "contao:fix_links", "deploy:cleanup"
|
76
|
-
after "deploy:restart", "
|
69
|
+
after "deploy:restart", "deploy:fix_permissions"
|
77
70
|
|
78
71
|
# Mysql Credentials
|
79
72
|
before "contao:setup_localconfig", "mysql:credentials"
|
@@ -15,6 +15,20 @@ Capistrano::Configuration.instance(:must_exist).load do
|
|
15
15
|
exit
|
16
16
|
end
|
17
17
|
end
|
18
|
+
|
19
|
+
desc "Fix permissions"
|
20
|
+
task :fix_permissions, :roles => :app do
|
21
|
+
unless exists?(:app_owner) or exists?(:app_group)
|
22
|
+
run <<-CMD
|
23
|
+
#{try_sudo} chown -R \
|
24
|
+
#{fetch :app_owner}:#{fetch :app_group} \
|
25
|
+
#{fetch :deploy_to}/releases \
|
26
|
+
#{fetch :deploy_to}/shared
|
27
|
+
CMD
|
28
|
+
end
|
29
|
+
|
30
|
+
run "chmod -R g+w #{fetch :latest_release}" if fetch(:group_writable, true)
|
31
|
+
end
|
18
32
|
end
|
19
33
|
|
20
34
|
# Dependencies
|
@@ -1,31 +1,28 @@
|
|
1
1
|
require 'capistrano'
|
2
|
-
require 'capistrano-exts/receipts/
|
2
|
+
require 'capistrano-exts/receipts/deploy'
|
3
3
|
|
4
4
|
# Verify that Capistrano is version 2
|
5
5
|
unless Capistrano::Configuration.respond_to?(:instance)
|
6
6
|
abort "This extension requires Capistrano 2"
|
7
7
|
end
|
8
8
|
|
9
|
+
# TODO:
|
10
|
+
# => Replace the vars with a call to fetch
|
11
|
+
# => Add the vars to examples and the template so it is visible
|
12
|
+
|
9
13
|
Capistrano::Configuration.instance(:must_exist).load do
|
10
14
|
|
11
15
|
namespace :rails do
|
12
16
|
desc "Install configuration files"
|
13
17
|
task :install_configuration_files, :roles => :app do
|
14
|
-
unless configuration_files
|
15
|
-
configuration_files.each { |configuration_file| link_config_file(configuration_file) }
|
18
|
+
unless exists?(:configuration_files)
|
19
|
+
fetch(:configuration_files).each { |configuration_file| link_config_file(configuration_file) }
|
16
20
|
end
|
17
21
|
end
|
18
22
|
|
19
23
|
desc "Install rvm config file"
|
20
24
|
task :install_rvmrc_file, :roles => :app do
|
21
|
-
link_file(File.join(shared_path, 'rvmrc'), File.join(release_path, '.rvmrc'))
|
22
|
-
end
|
23
|
-
|
24
|
-
desc "Fix permissions"
|
25
|
-
task :fix_permissions, :roles => :app do
|
26
|
-
unless app_owner.blank? or app_group.blank?
|
27
|
-
run "#{try_sudo} chown -R #{app_owner}:#{app_group} #{deploy_to}"
|
28
|
-
end
|
25
|
+
link_file(File.join(fetch(:shared_path), 'rvmrc'), File.join(fetch(:release_path), '.rvmrc'))
|
29
26
|
end
|
30
27
|
end
|
31
28
|
|
@@ -37,7 +34,7 @@ Capistrano::Configuration.instance(:must_exist).load do
|
|
37
34
|
|
38
35
|
after "deploy:finalize_update", "rails:install_configuration_files"
|
39
36
|
after "rails:install_configuration_files", "rails:install_rvmrc_file"
|
40
|
-
after "deploy:restart", "
|
37
|
+
after "deploy:restart", "deploy:fix_permissions"
|
41
38
|
|
42
39
|
# Capistrano is broken
|
43
40
|
# See: https://github.com/capistrano/capistrano/issues/81
|
@@ -37,14 +37,14 @@ Capistrano::Configuration.instance(:must_exist).load do
|
|
37
37
|
desc "Restart apache web server"
|
38
38
|
task :restart do
|
39
39
|
run <<-CMD
|
40
|
-
#{try_sudo} #{apache_init_path} restart
|
40
|
+
#{try_sudo} #{fetch :apache_init_path} restart
|
41
41
|
CMD
|
42
42
|
end
|
43
43
|
|
44
44
|
desc "Resload apache web server"
|
45
45
|
task :reload do
|
46
46
|
run <<-CMD
|
47
|
-
#{try_sudo} #{apache_init_path} reload
|
47
|
+
#{try_sudo} #{fetch :apache_init_path} reload
|
48
48
|
CMD
|
49
49
|
end
|
50
50
|
|
@@ -63,14 +63,14 @@ Capistrano::Configuration.instance(:must_exist).load do
|
|
63
63
|
desc "Restart nginx web server"
|
64
64
|
task :restart do
|
65
65
|
run <<-CMD
|
66
|
-
#{try_sudo} #{nginx_init_path} restart
|
66
|
+
#{try_sudo} #{fetch :nginx_init_path} restart
|
67
67
|
CMD
|
68
68
|
end
|
69
69
|
|
70
70
|
desc "Resload nginx web server"
|
71
71
|
task :reload do
|
72
72
|
run <<-CMD
|
73
|
-
#{try_sudo} #{nginx_init_path} reload
|
73
|
+
#{try_sudo} #{fetch :nginx_init_path} reload
|
74
74
|
CMD
|
75
75
|
end
|
76
76
|
|
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
# Requirements
|
4
4
|
require 'capistrano'
|
5
|
-
require 'capistrano-exts/receipts/
|
5
|
+
require 'capistrano-exts/receipts/deploy'
|
6
6
|
require 'capistrano-exts/receipts/mysql'
|
7
7
|
require 'capistrano-exts/receipts/servers/web_server'
|
8
8
|
require 'capistrano-exts/receipts/servers/db_server'
|
@@ -5,7 +5,7 @@ module Capistrano
|
|
5
5
|
module Server
|
6
6
|
class Nginx < WebServer
|
7
7
|
|
8
|
-
AVAILABLE_MODES = [:
|
8
|
+
AVAILABLE_MODES = [:passenger, :rails_reverse_proxy, :php_fpm]
|
9
9
|
NGINX_TEMPLATE_PATH = ROOT_PATH + '/capistrano-exts/templates/web_servers/nginx.conf.erb'
|
10
10
|
|
11
11
|
def initialize(mode, template_path = NGINX_TEMPLATE_PATH)
|
@@ -35,7 +35,7 @@ module Capistrano
|
|
35
35
|
end
|
36
36
|
|
37
37
|
def passenger?
|
38
|
-
@mode == :
|
38
|
+
@mode == :passenger
|
39
39
|
end
|
40
40
|
|
41
41
|
def php_build_with_force_cgi_redirect?
|
@@ -51,13 +51,37 @@ module Capistrano
|
|
51
51
|
end
|
52
52
|
|
53
53
|
if php_fpm?
|
54
|
-
[:php_fpm_host, :php_fpm_port
|
54
|
+
[:php_fpm_host, :php_fpm_port].each do |var|
|
55
55
|
unless instance_variable_get("@#{var.to_s}")
|
56
56
|
raise ArgumentError, "#{var.to_s} is required, please define it."
|
57
57
|
end
|
58
58
|
end
|
59
59
|
end
|
60
60
|
|
61
|
+
if reverse_proxy?
|
62
|
+
if @reverse_proxy_server_address.blank? and @reverse_proxy_server_port.blank? and @reverse_proxy_socket.blank?
|
63
|
+
raise ArgumentError, "None of the address, port or socket has been defined."
|
64
|
+
end
|
65
|
+
|
66
|
+
if @reverse_proxy_server_address.present? and @reverse_proxy_server_port.blank?
|
67
|
+
raise ArgumentError, "reverse_proxy_server_address is defined but reverse_proxy_server_port is not please define it."
|
68
|
+
end
|
69
|
+
|
70
|
+
if @reverse_proxy_server_port.present? and @reverse_proxy_server_address.blank?
|
71
|
+
raise ArgumentError, "reverse_proxy_server_port is defined but reverse_proxy_server_address is not please define it."
|
72
|
+
end
|
73
|
+
|
74
|
+
if @reverse_proxy_server_address.present? and @reverse_proxy_server_port.present? and @reverse_proxy_socket.present?
|
75
|
+
raise ArgumentError, "you should not define reverse_proxy_server_address, reverse_proxy_server_port and reverse_proxy_socket."
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
if passenger? or php_fpm?
|
80
|
+
if @public_path.blank?
|
81
|
+
raise ArgumentError, "public_path is required, please define it."
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
61
85
|
end
|
62
86
|
|
63
87
|
end
|
@@ -5,6 +5,10 @@ role :web, 'root@nasreddine.com:22'
|
|
5
5
|
role :app, 'root@nasreddine.com:22'
|
6
6
|
role :db, 'root@nasreddine.com:22', primary: true
|
7
7
|
|
8
|
+
# Permissions (ownership)
|
9
|
+
set :app_owner, 'www'
|
10
|
+
set :app_group, 'www'
|
11
|
+
|
8
12
|
# The project's branch to use
|
9
13
|
# Uncomment and edit this if you're using git, for other SCM's please refer
|
10
14
|
# to capistrano's documentation
|
@@ -89,9 +93,9 @@ set :web_server_mod_rewrite, true
|
|
89
93
|
# Valid options:
|
90
94
|
#
|
91
95
|
# For Nginx:
|
92
|
-
# => :rails_reverse_proxy, :
|
96
|
+
# => :rails_reverse_proxy, :passenger, :php_fpm
|
93
97
|
# => :rails_reverse_proxy is used for unicorn (Rack apps)
|
94
|
-
# => :
|
98
|
+
# => :passenger runs rails apps
|
95
99
|
# => :php_fpm is used to deliver websites written using PHP
|
96
100
|
#
|
97
101
|
# For Apache
|
@@ -88,7 +88,7 @@ upstream <%= @application %>_reverse_proxy {
|
|
88
88
|
server <%= @reverse_proxy_server_address %>:<%= @reverse_proxy_server_port %> fail_timeout=0;
|
89
89
|
<% end %>
|
90
90
|
|
91
|
-
<% if @reverse_proxy_socket.
|
91
|
+
<% if @reverse_proxy_socket.present? %>
|
92
92
|
server unix:<%= @reverse_proxy_socket %>;
|
93
93
|
<% end %>
|
94
94
|
}
|
data/spec/requests/nginx_spec.rb
CHANGED
@@ -21,12 +21,16 @@ describe Nginx do
|
|
21
21
|
subject { Nginx.new :php_fpm }
|
22
22
|
|
23
23
|
before(:each) do
|
24
|
-
subject.application_url = %w
|
24
|
+
subject.application_url = %w{example.com www.example.com}
|
25
25
|
subject.application = 'example'
|
26
26
|
subject.php_fpm_host = 'localhost'
|
27
27
|
subject.php_fpm_port = 60313
|
28
28
|
subject.public_path = '/path/to/application'
|
29
|
-
subject.indexes = %w
|
29
|
+
subject.indexes = %w{index.php}
|
30
|
+
end
|
31
|
+
|
32
|
+
it "should have php_fpm enabled" do
|
33
|
+
subject.send(:php_fpm?).should be_true
|
30
34
|
end
|
31
35
|
|
32
36
|
it "should require an 'application_url'" do
|
@@ -58,24 +62,72 @@ describe Nginx do
|
|
58
62
|
end
|
59
63
|
end
|
60
64
|
|
61
|
-
describe ":
|
62
|
-
subject { Nginx.new :
|
65
|
+
describe ":passenger" do
|
66
|
+
subject { Nginx.new :passenger }
|
67
|
+
|
68
|
+
before(:each) do
|
69
|
+
subject.application_url = %w{example.com www.example.com}
|
70
|
+
subject.application = 'example'
|
71
|
+
subject.public_path = '/path/to/application'
|
72
|
+
end
|
63
73
|
|
64
|
-
it "should require 'public_path'"
|
74
|
+
it "should require 'public_path'" do
|
75
|
+
subject.public_path = nil
|
76
|
+
lambda {
|
77
|
+
subject.render
|
78
|
+
}.should raise_error(ArgumentError, "public_path is required, please define it.")
|
79
|
+
end
|
65
80
|
|
66
|
-
it "should have passenger enabled"
|
81
|
+
it "should have passenger enabled" do
|
82
|
+
subject.send(:passenger?).should be_true
|
83
|
+
end
|
67
84
|
end
|
68
85
|
|
69
86
|
describe ":rails_reverse_proxy" do
|
70
87
|
subject { Nginx.new :rails_reverse_proxy }
|
71
88
|
|
72
|
-
|
89
|
+
before(:each) do
|
90
|
+
subject.application_url = %w{example.com www.example.com}
|
91
|
+
subject.application = 'example'
|
92
|
+
subject.reverse_proxy_server_address = 'localhost'
|
93
|
+
subject.reverse_proxy_server_port = 8080
|
94
|
+
end
|
73
95
|
|
74
|
-
it "should
|
96
|
+
it "should have reverse_proxy enabled" do
|
97
|
+
subject.send(:reverse_proxy?).should be_true
|
98
|
+
end
|
75
99
|
|
76
|
-
it "should require 'reverse_proxy_socket'"
|
100
|
+
it "should require 'reverse_proxy_server_address' and 'reverse_proxy_server_port' or 'reverse_proxy_socket'" do
|
101
|
+
subject.reverse_proxy_server_address = nil
|
102
|
+
subject.reverse_proxy_server_port = nil
|
103
|
+
lambda {
|
104
|
+
subject.render
|
105
|
+
}.should raise_error(ArgumentError, "None of the address, port or socket has been defined.")
|
106
|
+
end
|
107
|
+
|
108
|
+
it "should force defining reverse_proxy_server_port if reverse_proxy_server_address is defined" do
|
109
|
+
subject.reverse_proxy_server_address = 'localhost'
|
110
|
+
subject.reverse_proxy_server_port = nil
|
77
111
|
|
78
|
-
|
112
|
+
lambda {
|
113
|
+
subject.render
|
114
|
+
}.should raise_error(ArgumentError, "reverse_proxy_server_address is defined but reverse_proxy_server_port is not please define it.")
|
115
|
+
end
|
116
|
+
|
117
|
+
it "should force defining reverse_proxy_server_address if reverse_proxy_server_port is defined" do
|
118
|
+
subject.reverse_proxy_server_address = nil
|
119
|
+
subject.reverse_proxy_server_port = 8080
|
120
|
+
lambda {
|
121
|
+
subject.render
|
122
|
+
}.should raise_error(ArgumentError, "reverse_proxy_server_port is defined but reverse_proxy_server_address is not please define it.")
|
123
|
+
end
|
124
|
+
|
125
|
+
it "shouldn't allow defining both reverse_proxy_server_address and reverse_proxy_socket or reverse_proxy_server_port and reverse_proxy_socket" do
|
126
|
+
subject.reverse_proxy_socket = '/tmp/socket'
|
127
|
+
lambda {
|
128
|
+
subject.render
|
129
|
+
}.should raise_error(ArgumentError, "you should not define reverse_proxy_server_address, reverse_proxy_server_port and reverse_proxy_socket.")
|
130
|
+
end
|
79
131
|
end
|
80
132
|
end
|
81
133
|
|
@@ -84,12 +136,12 @@ describe Nginx do
|
|
84
136
|
subject { Nginx.new :php_fpm }
|
85
137
|
|
86
138
|
before(:each) do
|
87
|
-
subject.application_url = %w
|
139
|
+
subject.application_url = %w{example.com www.example.com}
|
88
140
|
subject.application = 'example'
|
89
141
|
subject.php_fpm_host = 'localhost'
|
90
142
|
subject.php_fpm_port = 60313
|
91
143
|
subject.public_path = '/path/to/application'
|
92
|
-
subject.indexes = %w
|
144
|
+
subject.indexes = %w{index.php}
|
93
145
|
end
|
94
146
|
|
95
147
|
it "should render 'public_path'" do |variable|
|
@@ -123,12 +175,12 @@ describe Nginx do
|
|
123
175
|
end
|
124
176
|
|
125
177
|
it "should render 'application_url'" do
|
126
|
-
subject.application_url = %w
|
178
|
+
subject.application_url = %w{technogate.fr www.technogate.fr}
|
127
179
|
subject.render.should =~ %r{server_name\s+technogate.fr www.technogate.fr;}
|
128
180
|
end
|
129
181
|
|
130
182
|
it "should render 'indexes'" do
|
131
|
-
subject.indexes = %w
|
183
|
+
subject.indexes = %w{index.php index.html}
|
132
184
|
subject.render.should =~ %r{index\s+index.php index.html;}
|
133
185
|
end
|
134
186
|
|
@@ -158,22 +210,47 @@ describe Nginx do
|
|
158
210
|
end
|
159
211
|
end
|
160
212
|
|
161
|
-
describe ":
|
162
|
-
subject { Nginx.new :
|
213
|
+
describe ":passenger" do
|
214
|
+
subject { Nginx.new :passenger }
|
163
215
|
|
164
|
-
|
216
|
+
before(:each) do
|
217
|
+
subject.application_url = %w{example.com www.example.com}
|
218
|
+
subject.application = 'example'
|
219
|
+
subject.public_path = '/path/to/application'
|
220
|
+
end
|
165
221
|
|
166
|
-
it "should
|
222
|
+
it "should render 'application_url'" do
|
223
|
+
subject.application_url = %w{technogate.fr www.technogate.fr}
|
224
|
+
subject.render.should =~ %r{technogate.fr www.technogate.fr}
|
225
|
+
end
|
167
226
|
end
|
168
227
|
|
169
228
|
describe ":rails_reverse_proxy" do
|
170
229
|
subject { Nginx.new :rails_reverse_proxy }
|
171
230
|
|
172
|
-
|
231
|
+
before(:each) do
|
232
|
+
subject.application_url = %w{example.com www.example.com}
|
233
|
+
subject.application = 'example'
|
234
|
+
subject.reverse_proxy_server_address = 'localhost'
|
235
|
+
subject.reverse_proxy_server_port = 8080
|
236
|
+
end
|
173
237
|
|
174
|
-
it "should render '
|
238
|
+
it "should render 'reverse_proxy_server_address'" do
|
239
|
+
subject.reverse_proxy_server_address = 'web_proxy'
|
240
|
+
subject.render.should =~ /upstream example_reverse_proxy .+server web_proxy:8080 fail_timeout=0;.+/m
|
241
|
+
end
|
175
242
|
|
176
|
-
it "should render '
|
243
|
+
it "should render 'reverse_proxy_server_port'" do
|
244
|
+
subject.reverse_proxy_server_port = 6565
|
245
|
+
subject.render.should =~ /upstream example_reverse_proxy .+server localhost:6565 fail_timeout=0;.+/m
|
246
|
+
end
|
247
|
+
|
248
|
+
it "should render 'reverse_proxy_socket'" do
|
249
|
+
subject.reverse_proxy_server_address = nil
|
250
|
+
subject.reverse_proxy_server_port = nil
|
251
|
+
subject.reverse_proxy_socket = "/tmp/socket"
|
252
|
+
subject.render.should =~ /upstream example_reverse_proxy .+server unix:\/tmp\/socket;.+/m
|
253
|
+
end
|
177
254
|
end
|
178
255
|
end
|
179
256
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: capistrano-exts
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,12 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2011-09-
|
13
|
-
default_executable:
|
12
|
+
date: 2011-09-03 00:00:00.000000000 Z
|
14
13
|
dependencies:
|
15
14
|
- !ruby/object:Gem::Dependency
|
16
15
|
name: capistrano
|
17
|
-
requirement: &
|
16
|
+
requirement: &2156371700 !ruby/object:Gem::Requirement
|
18
17
|
none: false
|
19
18
|
requirements:
|
20
19
|
- - ! '>='
|
@@ -22,10 +21,10 @@ dependencies:
|
|
22
21
|
version: 2.8.0
|
23
22
|
type: :runtime
|
24
23
|
prerelease: false
|
25
|
-
version_requirements: *
|
24
|
+
version_requirements: *2156371700
|
26
25
|
- !ruby/object:Gem::Dependency
|
27
26
|
name: i18n
|
28
|
-
requirement: &
|
27
|
+
requirement: &2156370900 !ruby/object:Gem::Requirement
|
29
28
|
none: false
|
30
29
|
requirements:
|
31
30
|
- - ! '>='
|
@@ -33,10 +32,10 @@ dependencies:
|
|
33
32
|
version: 0.6.0
|
34
33
|
type: :runtime
|
35
34
|
prerelease: false
|
36
|
-
version_requirements: *
|
35
|
+
version_requirements: *2156370900
|
37
36
|
- !ruby/object:Gem::Dependency
|
38
37
|
name: activesupport
|
39
|
-
requirement: &
|
38
|
+
requirement: &2156370320 !ruby/object:Gem::Requirement
|
40
39
|
none: false
|
41
40
|
requirements:
|
42
41
|
- - ! '>='
|
@@ -44,95 +43,84 @@ dependencies:
|
|
44
43
|
version: 3.1.0
|
45
44
|
type: :runtime
|
46
45
|
prerelease: false
|
47
|
-
version_requirements: *
|
46
|
+
version_requirements: *2156370320
|
48
47
|
- !ruby/object:Gem::Dependency
|
49
|
-
name:
|
50
|
-
requirement: &
|
48
|
+
name: guard
|
49
|
+
requirement: &2156384460 !ruby/object:Gem::Requirement
|
51
50
|
none: false
|
52
51
|
requirements:
|
53
52
|
- - ! '>='
|
54
53
|
- !ruby/object:Gem::Version
|
55
|
-
version:
|
54
|
+
version: 0.6.2
|
56
55
|
type: :development
|
57
56
|
prerelease: false
|
58
|
-
version_requirements: *
|
57
|
+
version_requirements: *2156384460
|
59
58
|
- !ruby/object:Gem::Dependency
|
60
|
-
name:
|
61
|
-
requirement: &
|
59
|
+
name: guard-bundler
|
60
|
+
requirement: &2156382840 !ruby/object:Gem::Requirement
|
62
61
|
none: false
|
63
62
|
requirements:
|
64
63
|
- - ! '>='
|
65
64
|
- !ruby/object:Gem::Version
|
66
|
-
version: 0.
|
65
|
+
version: 0.1.3
|
67
66
|
type: :development
|
68
67
|
prerelease: false
|
69
|
-
version_requirements: *
|
68
|
+
version_requirements: *2156382840
|
70
69
|
- !ruby/object:Gem::Dependency
|
71
|
-
name:
|
72
|
-
requirement: &
|
70
|
+
name: guard-rspec
|
71
|
+
requirement: &2156382080 !ruby/object:Gem::Requirement
|
73
72
|
none: false
|
74
73
|
requirements:
|
75
74
|
- - ! '>='
|
76
75
|
- !ruby/object:Gem::Version
|
77
|
-
version:
|
76
|
+
version: 0.4.3
|
78
77
|
type: :development
|
79
78
|
prerelease: false
|
80
|
-
version_requirements: *
|
79
|
+
version_requirements: *2156382080
|
81
80
|
- !ruby/object:Gem::Dependency
|
82
|
-
name:
|
83
|
-
requirement: &
|
81
|
+
name: rspec
|
82
|
+
requirement: &2156381120 !ruby/object:Gem::Requirement
|
84
83
|
none: false
|
85
84
|
requirements:
|
86
85
|
- - ! '>='
|
87
86
|
- !ruby/object:Gem::Version
|
88
|
-
version:
|
87
|
+
version: 2.6.0
|
89
88
|
type: :development
|
90
89
|
prerelease: false
|
91
|
-
version_requirements: *
|
90
|
+
version_requirements: *2156381120
|
92
91
|
- !ruby/object:Gem::Dependency
|
93
|
-
name:
|
94
|
-
requirement: &
|
92
|
+
name: mocha
|
93
|
+
requirement: &2156380360 !ruby/object:Gem::Requirement
|
95
94
|
none: false
|
96
95
|
requirements:
|
97
96
|
- - ! '>='
|
98
97
|
- !ruby/object:Gem::Version
|
99
|
-
version: 0.
|
98
|
+
version: 0.2.12
|
100
99
|
type: :development
|
101
100
|
prerelease: false
|
102
|
-
version_requirements: *
|
101
|
+
version_requirements: *2156380360
|
103
102
|
- !ruby/object:Gem::Dependency
|
104
|
-
name:
|
105
|
-
requirement: &
|
103
|
+
name: factory_girl
|
104
|
+
requirement: &2156379840 !ruby/object:Gem::Requirement
|
106
105
|
none: false
|
107
106
|
requirements:
|
108
107
|
- - ! '>='
|
109
108
|
- !ruby/object:Gem::Version
|
110
|
-
version: 0.
|
109
|
+
version: 2.0.5
|
111
110
|
type: :development
|
112
111
|
prerelease: false
|
113
|
-
version_requirements: *
|
112
|
+
version_requirements: *2156379840
|
114
113
|
- !ruby/object:Gem::Dependency
|
115
|
-
name:
|
116
|
-
requirement: &
|
114
|
+
name: faker19
|
115
|
+
requirement: &2156379320 !ruby/object:Gem::Requirement
|
117
116
|
none: false
|
118
117
|
requirements:
|
119
118
|
- - ! '>='
|
120
119
|
- !ruby/object:Gem::Version
|
121
|
-
version: 0.
|
122
|
-
type: :development
|
123
|
-
prerelease: false
|
124
|
-
version_requirements: *2153819160
|
125
|
-
- !ruby/object:Gem::Dependency
|
126
|
-
name: growl_notify
|
127
|
-
requirement: &2153818460 !ruby/object:Gem::Requirement
|
128
|
-
none: false
|
129
|
-
requirements:
|
130
|
-
- - =
|
131
|
-
- !ruby/object:Gem::Version
|
132
|
-
version: 0.0.1
|
120
|
+
version: 1.0.5
|
133
121
|
type: :development
|
134
122
|
prerelease: false
|
135
|
-
version_requirements: *
|
123
|
+
version_requirements: *2156379320
|
136
124
|
description: Handy extensions for Capistrano
|
137
125
|
email:
|
138
126
|
- wael.nasreddine@gmail.com
|
@@ -141,8 +129,11 @@ extensions: []
|
|
141
129
|
extra_rdoc_files: []
|
142
130
|
files:
|
143
131
|
- .gitignore
|
132
|
+
- .travis.yml
|
144
133
|
- Gemfile
|
145
134
|
- Guardfile
|
135
|
+
- MIT-LICENSE
|
136
|
+
- README.md
|
146
137
|
- Rakefile
|
147
138
|
- capistrano-exts.gemspec
|
148
139
|
- examples/php_fpm/deploy.rb
|
@@ -161,8 +152,8 @@ files:
|
|
161
152
|
- lib/capistrano-exts/core_ext.rb
|
162
153
|
- lib/capistrano-exts/core_ext/string/filters.rb
|
163
154
|
- lib/capistrano-exts/receipts.rb
|
164
|
-
- lib/capistrano-exts/receipts/base.rb
|
165
155
|
- lib/capistrano-exts/receipts/contao.rb
|
156
|
+
- lib/capistrano-exts/receipts/deploy.rb
|
166
157
|
- lib/capistrano-exts/receipts/functions.rb
|
167
158
|
- lib/capistrano-exts/receipts/git.rb
|
168
159
|
- lib/capistrano-exts/receipts/god.rb
|
@@ -187,7 +178,6 @@ files:
|
|
187
178
|
- spec/servers/web_server/nginx_spec.rb
|
188
179
|
- spec/spec_helper.rb
|
189
180
|
- spec/support/factories.rb
|
190
|
-
has_rdoc: true
|
191
181
|
homepage: https://github.com/Extensions/capistrano-exts
|
192
182
|
licenses: []
|
193
183
|
post_install_message:
|
@@ -208,7 +198,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
208
198
|
version: '0'
|
209
199
|
requirements: []
|
210
200
|
rubyforge_project: capistrano-exts
|
211
|
-
rubygems_version: 1.
|
201
|
+
rubygems_version: 1.8.10
|
212
202
|
signing_key:
|
213
203
|
specification_version: 3
|
214
204
|
summary: Handy extensions for Capistrano
|