capistrano_misc_recipes 0.1.0 → 0.2.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.
- data/.gitignore +1 -0
- data/README.md +4 -2
- data/lib/capistrano_misc_recipes/passenger.rb +35 -43
- data/lib/capistrano_misc_recipes/templates/god.erb +14 -0
- data/lib/capistrano_misc_recipes/templates/nginx.erb +32 -0
- data/lib/capistrano_misc_recipes/version.rb +1 -1
- metadata +6 -5
- data/lib/capistrano_misc_recipes/.passenger.rb.swo +0 -0
data/.gitignore
CHANGED
data/README.md
CHANGED
@@ -109,9 +109,11 @@ end
|
|
109
109
|
|
110
110
|
`passenger.start`, `passenger.stop` and `passenger.restart` tasks can be used.
|
111
111
|
|
112
|
-
### Generate sample
|
112
|
+
### Generate sample configs for god and nginx
|
113
113
|
|
114
|
-
Task `cap passenger:
|
114
|
+
Task `cap passenger:config:god` generates sample _god_ config and stores it in application tmp dir
|
115
|
+
|
116
|
+
Task `cap passenger:config:nginx` generates sample _nginx_ config and stores it in file application tmp dir
|
115
117
|
|
116
118
|
## Contributing
|
117
119
|
|
@@ -15,9 +15,9 @@ module Capistrano
|
|
15
15
|
_cset :passenger_port, 3000
|
16
16
|
_cset :passenger_use_socket, false
|
17
17
|
|
18
|
-
|
19
|
-
|
20
|
-
|
18
|
+
# command to start passenger
|
19
|
+
def start_command
|
20
|
+
# TODO try_sudo
|
21
21
|
|
22
22
|
command = []
|
23
23
|
command << "cd #{current_path}"
|
@@ -37,62 +37,54 @@ module Capistrano
|
|
37
37
|
command << "--pid-file #{passenger_pid_file}"
|
38
38
|
command << "--environment #{rails_env}"
|
39
39
|
command << "--daemonize"
|
40
|
-
|
40
|
+
command.join ' '
|
41
|
+
end
|
41
42
|
|
43
|
+
def stop_command
|
44
|
+
# TODO try_sudo
|
45
|
+
"cd #{current_path} && #{bundlify 'passenger'} stop --pid-file #{passenger_pid_file} ; true"
|
46
|
+
end
|
47
|
+
|
48
|
+
def restart_command
|
49
|
+
"#{try_sudo} touch #{File.join(current_path,'tmp','restart.txt')}"
|
50
|
+
end
|
51
|
+
|
52
|
+
desc '[internal] Start passenger'
|
53
|
+
task :start, roles: :app do
|
54
|
+
run start_command
|
42
55
|
end
|
43
56
|
|
44
57
|
desc '[internal] Stop passenger'
|
45
58
|
task :stop, roles: :app do
|
46
|
-
run
|
59
|
+
run stop_command
|
47
60
|
end
|
48
61
|
|
49
62
|
desc '[internal] Restart passenger'
|
50
63
|
task :restart, roles: :app, except: { no_release: true } do
|
51
|
-
run
|
64
|
+
run restart_command
|
52
65
|
end
|
53
66
|
|
54
|
-
|
55
|
-
task :nginx_config do
|
56
|
-
|
57
|
-
proxy_pass = if passenger_use_socket
|
58
|
-
"http://unix:#{passenger_socket_file}"
|
59
|
-
else
|
60
|
-
"http://#{passenger_address}:#{passenger_port}"
|
61
|
-
end
|
62
|
-
|
63
|
-
conf_file = <<CONF
|
67
|
+
namespace :config do
|
64
68
|
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
listen 80;
|
70
|
-
server_name #{application}
|
71
|
-
root #{File.join current_path, 'public'};
|
72
|
-
client_max_body_size 15M;
|
69
|
+
{
|
70
|
+
god: { extension: 'god' },
|
71
|
+
nginx: { extension: nil}
|
72
|
+
}.each do |key, data|
|
73
73
|
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
74
|
+
desc "generates nginx #{key} file"
|
75
|
+
task key do
|
76
|
+
template_dir = Pathname.new(File.dirname(__FILE__)).join 'templates'
|
77
|
+
app_name = [application, exists?(:stages) ? stage : nil].compact.join(?_)
|
78
|
+
file_name = [app_name, data[:extension]].compact.join ?.
|
79
|
+
conf_file = ERB.new(File.read(template_dir.join "#{key}.erb"), nil, '-').result binding
|
79
80
|
|
80
|
-
|
81
|
-
|
82
|
-
|
81
|
+
puts conf_file
|
82
|
+
# save file in application tmp dir
|
83
|
+
put conf_file, File.join(current_path, 'tmp', file_name).to_s
|
84
|
+
end
|
83
85
|
|
84
|
-
|
85
|
-
}
|
86
|
-
|
87
|
-
error_page 500 502 503 504 /500.html;
|
88
|
-
error_page 404 403 /404.html;
|
89
|
-
}
|
90
|
-
|
91
|
-
CONF
|
86
|
+
end
|
92
87
|
|
93
|
-
puts conf_file
|
94
|
-
# save file in application tmp dir
|
95
|
-
put conf_file, Pathname.new(current_path).join('tmp', [application, exists?(:stages) ? stage : nil].compact.join(?_)).to_s
|
96
88
|
end
|
97
89
|
|
98
90
|
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
God.watch do |w|
|
2
|
+
w.name = <%= app_name.inspect %>
|
3
|
+
w.start = <%= "su -l #{ user } -c '#{ start_command }'".inspect %>
|
4
|
+
w.stop = <%= "su -l #{ user } -c '#{ stop_command }'".inspect %>
|
5
|
+
w.pid_file = <%= passenger_pid_file.to_s.inspect %>
|
6
|
+
|
7
|
+
w.behavior(:clean_pid_file)
|
8
|
+
w.start_if do |start|
|
9
|
+
start.condition(:process_running) do |c|
|
10
|
+
c.interval = 10.minutes
|
11
|
+
c.running = false
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
# nginx virtual host file for
|
2
|
+
# application: <%= application %>
|
3
|
+
<% if exists? :stages -%>
|
4
|
+
# stage: <%#= stage %>
|
5
|
+
<% end -%>
|
6
|
+
#
|
7
|
+
|
8
|
+
server {
|
9
|
+
listen 80;
|
10
|
+
server_name <%= app_name %>;
|
11
|
+
root <%= File.join current_path, 'public' %>;
|
12
|
+
client_max_body_size 15M;
|
13
|
+
|
14
|
+
location / {
|
15
|
+
try_files /system/maintence.html
|
16
|
+
$uri $uri/index.html $uri.html
|
17
|
+
@passenger;
|
18
|
+
}
|
19
|
+
|
20
|
+
location @passenger {
|
21
|
+
proxy_set_header Host $host;
|
22
|
+
proxy_set_header X-Forwarded-For $remote_addr;
|
23
|
+
<% if passenger_use_socket -%>
|
24
|
+
proxy_pass "http://unix:<%= passenger_socket_file %>";
|
25
|
+
<% else -%>
|
26
|
+
proxy_pass "http://<% passenger_address %>:<% passenger_port %>";
|
27
|
+
<% end -%>
|
28
|
+
}
|
29
|
+
|
30
|
+
error_page 500 502 503 504 /500.html;
|
31
|
+
error_page 404 403 /404.html;
|
32
|
+
}
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: capistrano_misc_recipes
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-06-
|
12
|
+
date: 2013-06-30 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: capistrano
|
@@ -75,13 +75,14 @@ files:
|
|
75
75
|
- Rakefile
|
76
76
|
- capistrano_misc_recipes.gemspec
|
77
77
|
- lib/capistrano_misc_recipes.rb
|
78
|
-
- lib/capistrano_misc_recipes/.passenger.rb.swo
|
79
78
|
- lib/capistrano_misc_recipes/bundler.rb
|
80
79
|
- lib/capistrano_misc_recipes/console.rb
|
81
80
|
- lib/capistrano_misc_recipes/db_dump.rb
|
82
81
|
- lib/capistrano_misc_recipes/dbfetch.rb
|
83
82
|
- lib/capistrano_misc_recipes/passenger.rb
|
84
83
|
- lib/capistrano_misc_recipes/tasks.rb
|
84
|
+
- lib/capistrano_misc_recipes/templates/god.erb
|
85
|
+
- lib/capistrano_misc_recipes/templates/nginx.erb
|
85
86
|
- lib/capistrano_misc_recipes/version.rb
|
86
87
|
homepage: http://github.com/corlinus/capistrano_misc_recipes
|
87
88
|
licenses:
|
@@ -98,7 +99,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
98
99
|
version: '0'
|
99
100
|
segments:
|
100
101
|
- 0
|
101
|
-
hash:
|
102
|
+
hash: 1047313683594404599
|
102
103
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
103
104
|
none: false
|
104
105
|
requirements:
|
@@ -107,7 +108,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
107
108
|
version: '0'
|
108
109
|
segments:
|
109
110
|
- 0
|
110
|
-
hash:
|
111
|
+
hash: 1047313683594404599
|
111
112
|
requirements: []
|
112
113
|
rubyforge_project:
|
113
114
|
rubygems_version: 1.8.25
|
Binary file
|