h2ocube_rails_puma 0.0.7 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 069c801dbb866f1a321bed6d309cb2f8a9793364
4
- data.tar.gz: 54f420666e902f62146d1fa364417605e51d1f5a
3
+ metadata.gz: da3bb6f5824867cf585d7a261927049dddc19cef
4
+ data.tar.gz: cc732dec6ae17683fc68d6944fe1f68cb3703be2
5
5
  SHA512:
6
- metadata.gz: 56e0d47169d77cc8635f854337f062f62797a8126d4703c883331d9eaf1974e371ffc3eea6f93e0ab97dc34a2aaf8d9d9e61cc2ceb2c12f560d90b1514c5cab3
7
- data.tar.gz: 6c68514391a440f0de601d3bd28b2e73835c2ccf08589ec803d1ed2f517f20418e8b659469fa27609922028f155bed83fe197317797cb2e3dd822ae62d00a0f0
6
+ metadata.gz: 9d510bda50ff4721cab33d6741e5f0bcce610fe3e85b02f6ecc10fe8d28a12e61878a1add68db7ec6ef8296de810fbe9f6045dbc4e0d307acf8b9798bb611121
7
+ data.tar.gz: ce13bd9124817d603b1e1e2379064eeb7e9c7a4bd3f2fecb140b9a99366912e1369c7fc2db8798a3ed019f53e8ebea890bbb8cef90949e1c1a8a7525262e44fc
@@ -0,0 +1,2 @@
1
+ pkg/
2
+ .bundle
data/README.md CHANGED
@@ -8,7 +8,7 @@ Puma helper.
8
8
 
9
9
  Add this line to your application's Gemfile:
10
10
 
11
- gem 'h2ocube_rails_puma', group: [:development, :production]
11
+ gem 'h2ocube_rails_puma'
12
12
 
13
13
  And then execute:
14
14
 
@@ -20,31 +20,19 @@ Or install it yourself as:
20
20
 
21
21
  ## Usage
22
22
 
23
- # generate config/puma.rb
23
+ # generate config/deploy/templates/puma.rb.erb
24
24
  rails g h2ocube_rails_puma
25
25
 
26
26
  # Capfile
27
27
  require 'capistrano/puma'
28
28
 
29
- # deploy.rb
30
- set :puma_rb, 'config/puma.rb'
31
- set :puma_threads, '0:16'
32
- set :puma_workers, '2'
33
-
34
- Puma specific tasks for Capistrano v3:
35
-
36
- cap puma:start
37
- cap puma:stop
38
- cap puma:restart
39
- cap puma:phased_restart
40
- cap puma:cold_restart
41
-
42
29
  # nginx.conf
43
30
  upstream app {
44
31
  server unix:/root/app/shared/sockets/puma.sock fail_timeout=0;
45
32
  }
46
33
  server {
47
34
  listen 80;
35
+ listen [::]:80;
48
36
  server_name app.com;
49
37
  root /root/app/current/public;
50
38
  location / {
@@ -58,6 +46,7 @@ Puma specific tasks for Capistrano v3:
58
46
  proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
59
47
  proxy_set_header Host $http_host;
60
48
  proxy_set_header X-UA-Compatible IE=edge,chrome=1;
49
+ proxy_http_version 1.1;
61
50
  proxy_redirect off;
62
51
  proxy_pass http://app;
63
52
  }
@@ -66,6 +55,8 @@ Puma specific tasks for Capistrano v3:
66
55
  ## Include
67
56
 
68
57
  * puma https://github.com/puma/puma
58
+ * puma_worker_killer https://github.com/schneems/puma_worker_killer
59
+ * capistrano3-puma https://github.com/seuros/capistrano-puma
69
60
 
70
61
  ## Contributing
71
62
 
@@ -4,7 +4,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
4
 
5
5
  Gem::Specification.new do |spec|
6
6
  spec.name = 'h2ocube_rails_puma'
7
- spec.version = '0.0.7'
7
+ spec.version = '0.1.0'
8
8
  spec.authors = ['Ben']
9
9
  spec.email = ['ben@zfben.com']
10
10
  spec.description = 'Puma plugin for Rails and Capistrano'
@@ -18,4 +18,6 @@ Gem::Specification.new do |spec|
18
18
  spec.require_paths = ['lib']
19
19
 
20
20
  spec.add_dependency 'puma'
21
+ spec.add_dependency 'puma_worker_killer'
22
+ spec.add_dependency 'capistrano3-puma'
21
23
  end
@@ -1,9 +1,9 @@
1
1
  class H2ocubeRailsPumaGenerator < Rails::Generators::Base
2
2
  source_root File.expand_path('../source', __FILE__)
3
3
 
4
- desc 'Creates a puma.rb to your config/.'
4
+ desc 'Creates puma.rb.erb to your config/deploy/templates/.'
5
5
 
6
6
  def copy_puma_rb
7
- template 'puma.rb.erb', 'config/puma.rb'
7
+ copy_file 'puma.rb.erb', 'config/deploy/templates/puma.rb.erb'
8
8
  end
9
9
  end
@@ -1,11 +1,66 @@
1
- application_path = File.expand_path('../../', __FILE__)
1
+ #!/usr/bin/env puma
2
2
 
3
- stdout_redirect "#{application_path}/log/puma.stdout.log", "#{application_path}/log/puma.stderr.log"
3
+ directory '<%= current_path %>'
4
+ rackup "<%=fetch(:puma_rackup)%>"
5
+ environment '<%= fetch(:puma_env) %>'
6
+ <% if fetch(:puma_tag) %>
7
+ tag '<%= fetch(:puma_tag)%>'
8
+ <% end %>
9
+ pidfile "<%=fetch(:puma_pid)%>"
10
+ state_path "<%=fetch(:puma_state)%>"
11
+ stdout_redirect '<%=fetch(:puma_access_log)%>', '<%=fetch(:puma_error_log)%>', true
4
12
 
13
+
14
+ threads <%=fetch(:puma_threads).join(',')%>
15
+
16
+ <%= puma_plugins %>
17
+
18
+ <%= puma_bind %>
19
+ <% if fetch(:puma_control_app) %>
20
+ activate_control_app "<%= fetch(:puma_default_control_app) %>"
21
+ <% end %>
22
+ workers <%= puma_workers %>
23
+ <% if fetch(:puma_worker_timeout) %>
24
+ worker_timeout <%= fetch(:puma_worker_timeout).to_i %>
25
+ <% end %>
26
+
27
+ <% if puma_daemonize? %>
28
+ daemonize
29
+ <% end %>
30
+
31
+ <% if puma_preload_app? %>
5
32
  preload_app!
33
+ <% else %>
34
+ prune_bundler
35
+ <% end %>
36
+
37
+ on_restart do
38
+ puts 'Refreshing Gemfile'
39
+ ENV["BUNDLE_GEMFILE"] = "<%= fetch(:bundle_gemfile, "#{current_path}/Gemfile") %>"
40
+ end
41
+
42
+ <% if puma_preload_app? and fetch(:puma_init_active_record) %>
43
+ before_fork do
44
+ ActiveRecord::Base.connection_pool.disconnect!
45
+
46
+ if RUBY_PLATFORM.match?(/linux/)
47
+ require 'puma_worker_killer'
48
+
49
+ PumaWorkerKiller.config do |config|
50
+ config.ram = (`free`.lines.to_a[1].split[1].to_i / 1024).to_i
51
+ config.frequency = 30
52
+ config.percent_usage = 0.5
53
+ config.rolling_restart_frequency = 8 * 3600
54
+ config.reaper_status_logs = true
55
+ end
56
+
57
+ PumaWorkerKiller.start
58
+ end
59
+ end
6
60
 
7
61
  on_worker_boot do
8
62
  ActiveSupport.on_load(:active_record) do
9
63
  ActiveRecord::Base.establish_connection
10
64
  end
11
65
  end
66
+ <% end %>
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: h2ocube_rails_puma
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.7
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ben
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-11-09 00:00:00.000000000 Z
11
+ date: 2017-03-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: puma
@@ -24,6 +24,34 @@ dependencies:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: puma_worker_killer
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: capistrano3-puma
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
27
55
  description: Puma plugin for Rails and Capistrano
28
56
  email:
29
57
  - ben@zfben.com
@@ -32,14 +60,13 @@ extensions: []
32
60
  extra_rdoc_files: []
33
61
  files:
34
62
  - ".bundle/install.log"
63
+ - ".gitignore"
35
64
  - Gemfile
36
65
  - Gemfile.lock
37
66
  - LICENSE.txt
38
67
  - README.md
39
68
  - Rakefile
40
69
  - h2ocube_rails_puma.gemspec
41
- - lib/capistrano/puma.rb
42
- - lib/capistrano/tasks/puma.cap
43
70
  - lib/generators/h2ocube_rails_puma_generator.rb
44
71
  - lib/generators/source/puma.rb.erb
45
72
  - lib/h2ocube_rails_puma.rb
@@ -63,7 +90,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
63
90
  version: '0'
64
91
  requirements: []
65
92
  rubyforge_project:
66
- rubygems_version: 2.4.8
93
+ rubygems_version: 2.6.8
67
94
  signing_key:
68
95
  specification_version: 4
69
96
  summary: Puma plugin for Rails and Capistrano
@@ -1 +0,0 @@
1
- load File.expand_path('../tasks/puma.cap', __FILE__)
@@ -1,54 +0,0 @@
1
- set :puma_rb, 'config/puma.rb'
2
- set :puma_threads, '0:16'
3
- set :puma_workers, '2'
4
-
5
- namespace :puma do
6
- desc 'Start puma'
7
- task :start do
8
- on roles :app do
9
- within release_path do
10
- execute :bundle, "exec puma -C #{fetch :puma_rb} -b 'unix://#{shared_path}/sockets/puma.sock' -t #{fetch :puma_threads} -w #{fetch :puma_workers} --pidfile #{shared_path}/pids/puma.pid -S #{state_path} -e #{fetch :stage} -d"
11
- end
12
- end
13
- end
14
-
15
- desc 'Stop puma'
16
- task :stop do
17
- on roles :app do
18
- within release_path do
19
- execute :bundle, "exec pumactl -S #{state_path} stop;true"
20
- end
21
- end
22
- end
23
-
24
- desc 'Restart puma'
25
- task :restart do
26
- on roles :app do
27
- within release_path do
28
- execute :bundle, "exec pumactl -S #{state_path} restart;true"
29
- end
30
- end
31
- end
32
-
33
- desc 'Phased restart puma'
34
- task :phased_restart do
35
- on roles :app do
36
- within release_path do
37
- execute :bundle, "exec pumactl -S #{state_path} phased-restart;true"
38
- end
39
- end
40
- end
41
-
42
- desc 'Cold Restart puma'
43
- task :cold_restart do
44
- invoke 'puma:stop'
45
- sleep 1
46
- invoke 'puma:start'
47
- end
48
-
49
- def state_path
50
- "#{shared_path}/sockets/puma.state"
51
- end
52
-
53
- before 'deploy:published', 'puma:cold_restart'
54
- end