caploy 0.1.5 → 0.1.6
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/caploy/recipes/defaults.rb +30 -1
- data/lib/caploy/recipes/nginx.rb +4 -3
- data/lib/caploy/recipes/setup.rb +9 -4
- data/lib/caploy/recipes/symlink.rb +1 -1
- data/lib/caploy/recipes/unicorn.rb +19 -20
- data/lib/caploy/templates/nginx/vhost.erb +11 -28
- data/lib/caploy/version.rb +1 -1
- metadata +10 -10
@@ -5,7 +5,7 @@ Capistrano::Configuration.instance.load do
|
|
5
5
|
set :keep_releases, 10
|
6
6
|
set :use_sudo, false
|
7
7
|
|
8
|
-
set :
|
8
|
+
set :nginx_protocol, :both
|
9
9
|
|
10
10
|
set :scm, :git
|
11
11
|
set :git_enable_submodules, false
|
@@ -25,6 +25,35 @@ Capistrano::Configuration.instance.load do
|
|
25
25
|
# if you want to remove the dump file after loading
|
26
26
|
set :db_local_clean, true
|
27
27
|
|
28
|
+
namespace :deploy do
|
29
|
+
desc "deploy always with migrations"
|
30
|
+
task :default do
|
31
|
+
deploy.migrations
|
32
|
+
end
|
33
|
+
|
34
|
+
namespace :cache do
|
35
|
+
desc "Flush cache"
|
36
|
+
task :clear, :roles => :app do
|
37
|
+
run "cd #{current_path} && #{rake} cache:clear RAILS_ENV=#{stage}"
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
task :set_branch_info_file, :roles => :app do
|
42
|
+
run "cd #{release_path} && echo \"#{branch}\" > CURRENT_BRANCH"
|
43
|
+
end
|
44
|
+
|
45
|
+
desc "build missing paperclip styles"
|
46
|
+
task :build_missing_paperclip_styles, :roles => :app do
|
47
|
+
run "cd #{current_path}; RAILS_ENV=#{rails_env} bundle exec rake paperclip:refresh:missing_styles"
|
48
|
+
end
|
49
|
+
|
50
|
+
desc 'Show deployed revision'
|
51
|
+
task :revision, :roles => :app do
|
52
|
+
run "cat #{current_path}/REVISION"
|
53
|
+
end
|
54
|
+
|
55
|
+
end
|
56
|
+
|
28
57
|
task :test_and_prepare_cap_env do
|
29
58
|
abort "You must set :user before using defaults" unless fetch(:user, nil)
|
30
59
|
abort "You must set :repository before using defaults" unless fetch(:repository, nil)
|
data/lib/caploy/recipes/nginx.rb
CHANGED
@@ -28,7 +28,7 @@ Capistrano::Configuration.instance.load do
|
|
28
28
|
end
|
29
29
|
|
30
30
|
task :setup, :roles => :web do
|
31
|
-
protocol = fetch(:
|
31
|
+
protocol = fetch(:nginx_protocol, nil).to_s
|
32
32
|
template_path = File.expand_path('../../templates/nginx/vhost.erb', __FILE__)
|
33
33
|
vars = {
|
34
34
|
'application' => application,
|
@@ -46,7 +46,8 @@ Capistrano::Configuration.instance.load do
|
|
46
46
|
'optional_nginx_https_content' => fetch(:optional_nginx_https_content, ''),
|
47
47
|
'cert_type' => fetch(:cert_type, 'pem'),
|
48
48
|
'key_type' => fetch(:cert_type, 'key'),
|
49
|
-
'serve_static_files' => fetch(:
|
49
|
+
'serve_static_files' => fetch(:nginx_serve_static_files, true),
|
50
|
+
'new_relic_support' => fetch(:nginx_new_relic_support, false)
|
50
51
|
}
|
51
52
|
|
52
53
|
sites_path = fetch(:nginx_sites_enabled_path, "/etc/nginx/sites-enabled")
|
@@ -76,7 +77,7 @@ Capistrano::Configuration.instance.load do
|
|
76
77
|
end
|
77
78
|
|
78
79
|
task :uninstall do
|
79
|
-
protocol = fetch(:
|
80
|
+
protocol = fetch(:nginx_protocol, nil)
|
80
81
|
sites_path = fetch(:nginx_sites_enabled_path, "/etc/nginx/sites-enabled")
|
81
82
|
|
82
83
|
with_user(fetch(:setup_user, user)) do
|
data/lib/caploy/recipes/setup.rb
CHANGED
@@ -5,7 +5,8 @@ Capistrano::Configuration.instance.load do
|
|
5
5
|
task :create_config_files, :roles => :app do
|
6
6
|
run "mkdir -p #{shared_path}/config/"
|
7
7
|
config_file_to_setup.each do |config_file|
|
8
|
-
|
8
|
+
local_path = config_file_path(config_file)
|
9
|
+
put(File.read(local_path), "#{shared_path}/config/#{config_file}", :via => :scp) if local_path
|
9
10
|
end
|
10
11
|
end
|
11
12
|
|
@@ -20,7 +21,7 @@ Capistrano::Configuration.instance.load do
|
|
20
21
|
|
21
22
|
task :database, :roles => :db do
|
22
23
|
_cset :db_admin_user, 'root'
|
23
|
-
_cset :db_admin_password, Capistrano::CLI.password_prompt("
|
24
|
+
_cset :db_admin_password, Capistrano::CLI.password_prompt("\e[0;31mType your mysql password for user '#{db_admin_user}' (not set if empty and ENTER): ")
|
24
25
|
_cset :db_name, application.gsub(/\W+/, '')[0..5] + '_' + rails_env.to_s
|
25
26
|
_cset :db_user_name, application
|
26
27
|
_cset :db_user_password, ''
|
@@ -44,8 +45,12 @@ end
|
|
44
45
|
|
45
46
|
def config_file_path(config_file_name)
|
46
47
|
config_file = "#{rails_root}/config/#{config_file_name}"
|
47
|
-
|
48
|
-
|
48
|
+
if File.exists? config_file
|
49
|
+
config_file
|
50
|
+
else
|
51
|
+
puts "\e[0;31mNo config file '#{config_file}'"
|
52
|
+
nil
|
53
|
+
end
|
49
54
|
end
|
50
55
|
|
51
56
|
def database_exits?
|
@@ -4,7 +4,7 @@ Capistrano::Configuration.instance.load do
|
|
4
4
|
desc <<-DESC
|
5
5
|
Symlink shared directories and files.
|
6
6
|
DESC
|
7
|
-
task :symlink_dependencies, :roles => :
|
7
|
+
task :symlink_dependencies, :roles => :app, :except => {:no_release => true} do
|
8
8
|
shared_directories_to_link = fetch(:shared_directories_to_link, [])
|
9
9
|
directories_to_create = fetch(:directories_to_create, [])
|
10
10
|
files_to_delete = fetch(:files_to_delete, [])
|
@@ -103,29 +103,28 @@ module Unicorn
|
|
103
103
|
end
|
104
104
|
end
|
105
105
|
end
|
106
|
-
end
|
107
|
-
|
108
|
-
after "deploy:restart", "unicorn:reload"
|
109
106
|
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
107
|
+
desc "Setup unicorn"
|
108
|
+
task :setup, :roles => :app, :except => {:no_release => true} do
|
109
|
+
run "mkdir -p \"#{shared_path}/config/unicorn\""
|
110
|
+
config_path = "#{shared_path}/config/unicorn/#{rails_env}.rb"
|
111
|
+
template_path = File.expand_path('../../templates/unicorn/unicorn.rb.erb', __FILE__)
|
112
|
+
vars = {
|
113
|
+
'application' => application,
|
114
|
+
'current_path' => current_path,
|
115
|
+
'unicorn_pid' => unicorn_pid,
|
116
|
+
'unicorn_std_log' => unicorn_std_log,
|
117
|
+
'unicorn_err_log' => unicorn_err_log,
|
118
|
+
'stage' => stage,
|
119
|
+
'unicorn_listen_backlog' => unicorn_listen_backlog,
|
120
|
+
'unicorn_worker_processes' => unicorn_worker_processes,
|
121
|
+
'sidekiq_redis_count' => sidekiq_redis_count
|
122
|
+
}
|
123
|
+
put(render_erb_template(template_path, vars), config_path)
|
124
|
+
end
|
127
125
|
end
|
128
126
|
|
127
|
+
after :"deploy:restart", :"unicorn:reload"
|
129
128
|
after :"deploy:setup", :"unicorn:setup";
|
130
129
|
|
131
130
|
namespace :deploy do
|
@@ -20,71 +20,53 @@ upstream <%= application %>_<%= stage %>_<%= protocol %>_server {
|
|
20
20
|
<%= optional_nginx_https_content if protocol == 'https' %>
|
21
21
|
|
22
22
|
server {
|
23
|
-
|
24
23
|
server_name <%= domain %>;
|
25
|
-
|
26
24
|
<% if protocol == 'https' %>
|
27
|
-
|
28
25
|
listen 443 ssl;
|
29
26
|
|
30
27
|
ssl_certificate <%= nginx_cert_dir %>/<%= application %>_cert.<%= cert_type %>;
|
31
28
|
ssl_certificate_key <%= nginx_cert_dir %>/<%= application %>_cert.<%= key_type %>;
|
32
|
-
|
33
29
|
#ssl_ciphers SSLv3+HIGH:RC4+MEDIUM:!aNULL:!eNULL:!3DES:!MD5:@STRENGTH;
|
34
30
|
#ssl_prefer_server_ciphers on;
|
35
31
|
#ssl_protocols SSLv3;
|
36
32
|
#ssl_session_cache shared:SSL:10m;
|
37
33
|
|
38
34
|
keepalive_timeout 70;
|
39
|
-
|
40
35
|
<% else %>
|
41
|
-
|
42
36
|
listen 80;
|
43
37
|
|
44
38
|
# ~2 seconds is often enough for most folks to parse HTML/CSS and
|
45
39
|
# retrieve needed images/icons/frames, connections are cheap in
|
46
40
|
# nginx so increasing this is generally safe...
|
47
41
|
#keepalive_timeout 5;
|
48
|
-
|
49
42
|
<% end %>
|
50
43
|
|
51
44
|
client_max_body_size 4G;
|
52
45
|
|
53
46
|
<% if serve_static_files %>
|
54
|
-
|
55
47
|
# path for static files
|
56
48
|
root <%= project_root %>/public;
|
57
|
-
|
58
49
|
<% if with_file_expire_max %>
|
59
50
|
location ~* \.(ico|css|js|gif|jpe?g|png)(\?[0-9]+)?$ {
|
60
51
|
expires max;
|
61
52
|
break;
|
62
53
|
}
|
63
54
|
<% end %>
|
64
|
-
|
65
55
|
<% end %>
|
56
|
+
<%= optional_http_content if protocol == 'http' %>
|
57
|
+
<%= optional_https_content if protocol == 'https' %>
|
66
58
|
|
67
|
-
|
68
|
-
|
59
|
+
location / {
|
60
|
+
# headers we want forwarded to the upstream server
|
69
61
|
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
# try_files directive appeared in in nginx 0.7.27 and has stabilized
|
74
|
-
# over time. Older versions of nginx (e.g. 0.6.x) requires
|
75
|
-
# "if (!-f $request_filename)" which was less efficient:
|
76
|
-
# http://bogomips.org/unicorn.git/tree/examples/nginx.conf?id=v3.3.1#n127
|
77
|
-
try_files $uri/index.html $uri.html $uri @app;
|
62
|
+
<% if new_relic_support %>
|
63
|
+
proxy_set_header X-Queue-Start "t=${msec}000";
|
64
|
+
<% end %>
|
78
65
|
|
79
|
-
location / {
|
80
66
|
# an HTTP header important enough to have its own Wikipedia entry:
|
81
67
|
# http://en.wikipedia.org/wiki/X-Forwarded-For
|
82
68
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
83
69
|
|
84
|
-
# enable this if and only if you use HTTPS, this helps Rack
|
85
|
-
# set the proper protocol for doing redirects:
|
86
|
-
# proxy_set_header X-Forwarded-Proto https;
|
87
|
-
|
88
70
|
# pass the Host: header from the client right along so redirects
|
89
71
|
# can be set properly within the Rack application
|
90
72
|
proxy_set_header Host $http_host;
|
@@ -106,6 +88,8 @@ server {
|
|
106
88
|
# proxy_buffering off;
|
107
89
|
|
108
90
|
<% if protocol == 'https' %>
|
91
|
+
# enable this if and only if you use HTTPS, this helps Rack
|
92
|
+
# set the proper protocol for doing redirects:
|
109
93
|
# This makes sure that Rack::SslEnforcer knows it's being accessed over SSL.
|
110
94
|
proxy_set_header X-Forwarded-Proto https;
|
111
95
|
<% end %>
|
@@ -114,11 +98,10 @@ server {
|
|
114
98
|
proxy_pass http://<%= application %>_<%= stage %>_<%= protocol %>_server;
|
115
99
|
break;
|
116
100
|
}
|
117
|
-
|
118
|
-
<% if auth_basic_title %>
|
101
|
+
<% if auth_basic_title %>
|
119
102
|
auth_basic "<%= auth_basic_title %>";
|
120
103
|
auth_basic_user_file <%= auth_basic_password_file %>;
|
121
|
-
|
104
|
+
<% end %>
|
122
105
|
}
|
123
106
|
|
124
107
|
# Rails error pages
|
data/lib/caploy/version.rb
CHANGED
metadata
CHANGED
@@ -1,25 +1,25 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: caploy
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.5
|
5
4
|
prerelease:
|
5
|
+
version: 0.1.6
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Michael Schiller
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-
|
12
|
+
date: 2013-02-03 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: gemcutter
|
16
|
+
type: :runtime
|
16
17
|
requirement: !ruby/object:Gem::Requirement
|
17
18
|
none: false
|
18
19
|
requirements:
|
19
20
|
- - ! '>='
|
20
21
|
- !ruby/object:Gem::Version
|
21
22
|
version: '0'
|
22
|
-
type: :runtime
|
23
23
|
prerelease: false
|
24
24
|
version_requirements: !ruby/object:Gem::Requirement
|
25
25
|
none: false
|
@@ -29,13 +29,13 @@ dependencies:
|
|
29
29
|
version: '0'
|
30
30
|
- !ruby/object:Gem::Dependency
|
31
31
|
name: capistrano
|
32
|
+
type: :runtime
|
32
33
|
requirement: !ruby/object:Gem::Requirement
|
33
34
|
none: false
|
34
35
|
requirements:
|
35
36
|
- - ! '>='
|
36
37
|
- !ruby/object:Gem::Version
|
37
38
|
version: 2.13.4
|
38
|
-
type: :runtime
|
39
39
|
prerelease: false
|
40
40
|
version_requirements: !ruby/object:Gem::Requirement
|
41
41
|
none: false
|
@@ -45,13 +45,13 @@ dependencies:
|
|
45
45
|
version: 2.13.4
|
46
46
|
- !ruby/object:Gem::Dependency
|
47
47
|
name: capistrano-ext
|
48
|
+
type: :runtime
|
48
49
|
requirement: !ruby/object:Gem::Requirement
|
49
50
|
none: false
|
50
51
|
requirements:
|
51
52
|
- - ! '>='
|
52
53
|
- !ruby/object:Gem::Version
|
53
54
|
version: 1.2.1
|
54
|
-
type: :runtime
|
55
55
|
prerelease: false
|
56
56
|
version_requirements: !ruby/object:Gem::Requirement
|
57
57
|
none: false
|
@@ -61,13 +61,13 @@ dependencies:
|
|
61
61
|
version: 1.2.1
|
62
62
|
- !ruby/object:Gem::Dependency
|
63
63
|
name: capistrano_colors
|
64
|
+
type: :runtime
|
64
65
|
requirement: !ruby/object:Gem::Requirement
|
65
66
|
none: false
|
66
67
|
requirements:
|
67
68
|
- - ! '>='
|
68
69
|
- !ruby/object:Gem::Version
|
69
70
|
version: 0.5.5
|
70
|
-
type: :runtime
|
71
71
|
prerelease: false
|
72
72
|
version_requirements: !ruby/object:Gem::Requirement
|
73
73
|
none: false
|
@@ -77,13 +77,13 @@ dependencies:
|
|
77
77
|
version: 0.5.5
|
78
78
|
- !ruby/object:Gem::Dependency
|
79
79
|
name: capistrano-file_db
|
80
|
+
type: :runtime
|
80
81
|
requirement: !ruby/object:Gem::Requirement
|
81
82
|
none: false
|
82
83
|
requirements:
|
83
84
|
- - ! '>='
|
84
85
|
- !ruby/object:Gem::Version
|
85
86
|
version: 0.1.0
|
86
|
-
type: :runtime
|
87
87
|
prerelease: false
|
88
88
|
version_requirements: !ruby/object:Gem::Requirement
|
89
89
|
none: false
|
@@ -93,13 +93,13 @@ dependencies:
|
|
93
93
|
version: 0.1.0
|
94
94
|
- !ruby/object:Gem::Dependency
|
95
95
|
name: capistrano-uptodate
|
96
|
+
type: :runtime
|
96
97
|
requirement: !ruby/object:Gem::Requirement
|
97
98
|
none: false
|
98
99
|
requirements:
|
99
100
|
- - ! '>='
|
100
101
|
- !ruby/object:Gem::Version
|
101
102
|
version: 0.0.2
|
102
|
-
type: :runtime
|
103
103
|
prerelease: false
|
104
104
|
version_requirements: !ruby/object:Gem::Requirement
|
105
105
|
none: false
|
@@ -109,13 +109,13 @@ dependencies:
|
|
109
109
|
version: 0.0.2
|
110
110
|
- !ruby/object:Gem::Dependency
|
111
111
|
name: rvm-capistrano
|
112
|
+
type: :runtime
|
112
113
|
requirement: !ruby/object:Gem::Requirement
|
113
114
|
none: false
|
114
115
|
requirements:
|
115
116
|
- - ! '>='
|
116
117
|
- !ruby/object:Gem::Version
|
117
118
|
version: 1.2.2
|
118
|
-
type: :runtime
|
119
119
|
prerelease: false
|
120
120
|
version_requirements: !ruby/object:Gem::Requirement
|
121
121
|
none: false
|
@@ -125,13 +125,13 @@ dependencies:
|
|
125
125
|
version: 1.2.2
|
126
126
|
- !ruby/object:Gem::Dependency
|
127
127
|
name: erubis
|
128
|
+
type: :runtime
|
128
129
|
requirement: !ruby/object:Gem::Requirement
|
129
130
|
none: false
|
130
131
|
requirements:
|
131
132
|
- - ! '>='
|
132
133
|
- !ruby/object:Gem::Version
|
133
134
|
version: '0'
|
134
|
-
type: :runtime
|
135
135
|
prerelease: false
|
136
136
|
version_requirements: !ruby/object:Gem::Requirement
|
137
137
|
none: false
|