puma-heroku 1.0.0 → 1.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
- SHA1:
3
- metadata.gz: 283944cd07f62a4882eb07c711d06ccc9b611e0e
4
- data.tar.gz: 01bac0bcaf41efac22a9a4fe8c0f6924fac22a1a
2
+ SHA256:
3
+ metadata.gz: 216d3ac5271277c9fd8fdbd5609a1821bf1ca092310bfbeda0c93ceed20747ef
4
+ data.tar.gz: 1f87bd9dadc93c0f27dce7c2a235d9c2d4eeca405739ed0952401e3eda43440e
5
5
  SHA512:
6
- metadata.gz: 37d8b04544d39146b3269e5cdd42ec73bb28ac9a5d75cda610ddaf72640b04f1c10723b90546106edbb6016a288e5b266e167bb08c032a85bbe64d9a528da489
7
- data.tar.gz: ee513de4d0e120f7f1c5af3a1b2433afa87e3e8d4c4b3f9cc6379d29259897b6d2c7c23712738d19cb193f5f4b3557b20a845938b6727e64d266e5266bcf854e
6
+ metadata.gz: eba79fb8ca09ddc005480a21a277308b31368f54fada4459c247fe5dbe6140e6610efa4fe8aa13753be8e2c8ddc4ff1ed7f635e53581b88c48f8bdaf52e0cebf
7
+ data.tar.gz: 5500a25ba768c628cd85b6548d9003e6f2dda68174f9761779b2170a0eff0e77d36c0a27dad8a6eb80c9ddb51160b02fe417eed56ab1441be80c2ee8c31d720f
data/README.md CHANGED
@@ -1,8 +1,9 @@
1
- # Puma::Heroku
1
+ # puma-heroku
2
2
 
3
- Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/puma/heroku`. To experiment with that code, run `bin/console` for an interactive prompt.
3
+ A Puma plugin with best-practices configuration and handy configuration
4
+ variables for Heroku deployments.
4
5
 
5
- TODO: Delete this and the text above, and describe your gem
6
+ You can read Heroku's documentation on the topic [here](https://devcenter.heroku.com/articles/deploying-rails-applications-with-the-puma-web-server). Most of the ideas there apply to all ruby apps running on Puma. Important Note: In that article, Heroku uses a different (rails-specific) environment variable for configuring threads. This plugin uses the generic `MAX_THREADS`, but will use `RAILS_MAX_THREADS` if available.
6
7
 
7
8
  ## Installation
8
9
 
@@ -19,23 +20,22 @@ And then execute:
19
20
  Or install it yourself as:
20
21
 
21
22
  $ gem install puma-heroku
23
+
24
+ Then add to your puma config.rb:
22
25
 
23
- ## Usage
24
-
25
- TODO: Write usage instructions here
26
-
27
- ## Development
26
+ # config/puma.rb
27
+ plugin 'heroku'
28
28
 
29
- After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
30
29
 
31
- To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
30
+ ## Usage
32
31
 
33
- ## Contributing
32
+ Read about how to configure puma to use this plugin here: https://github.com/puma/puma#plugins
34
33
 
35
- Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/puma-heroku.
34
+ There are two variables this plugin reads from the environment which control its behavior.
36
35
 
36
+ * `WEB_CONCURRENCY` — How many workers to run. This will be ignored on JRuby and Windows, where only 1 worker will be run.
37
+ * `MAX_THREADS` — The number of threads to run per worker. Note that this also sets the minimum number of threads to the same value, which is a recommended approach, especially in a single-app environment such as Heroku. If you are using Rails, you may want to use `RAILS_MAX_THREADS` instead, which is also supported.
37
38
 
38
39
  ## License
39
40
 
40
41
  The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
41
-
data/Rakefile CHANGED
@@ -1,10 +1 @@
1
1
  require "bundler/gem_tasks"
2
- require "rake/testtask"
3
-
4
- Rake::TestTask.new(:test) do |t|
5
- t.libs << "test"
6
- t.libs << "lib"
7
- t.test_files = FileList['test/**/*_test.rb']
8
- end
9
-
10
- task :default => :spec
@@ -1,26 +1,23 @@
1
1
  Puma::Plugin.create do
2
2
  def config(c)
3
-
4
- threads_count = Integer(ENV['MAX_THREADS'] || 5)
3
+ workers_count = Integer(ENV['WEB_CONCURRENCY'] || 1)
4
+ threads_count = Integer(ENV['RAILS_MAX_THREADS'] || ENV['MAX_THREADS'] || 5)
5
5
  c.threads threads_count, threads_count
6
6
 
7
- c.preload_app!
8
-
9
7
  c.port ENV['PORT'] || 3000
10
- c.environment ENV['RACK_ENV'] || 'development'
8
+ c.environment ENV['RACK_ENV'] || ENV['RAILS_ENV'] || 'development'
11
9
 
12
- if workers_supported?
13
- c.workers Integer(ENV['WEB_CONCURRENCY'] || 2)
10
+ if workers_supported? && workers_count > 1
11
+ c.preload_app!
12
+ c.workers workers_count
14
13
 
15
- c.on_worker_boot do
16
- if defined?(::ActiveRecord) && defined?(::ActiveRecord::Base)
17
- # Worker specific setup for Rails 4.1+
18
- # See: https://devcenter.heroku.com/articles/deploying-rails-applications-with-the-puma-web-server#on-worker-boot
19
- ActiveRecord::Base.establish_connection
20
- end
14
+ # Not necessary in Rails 5.2+, see https://github.com/rails/rails/pull/29807
15
+ if defined?(::ActiveRecord) && defined?(::ActiveRecord::Base) && Gem::Version.new(Rails.version) < Gem::Version.new('5.2.0')
16
+ c.before_fork { ActiveRecord::Base.connection_pool.disconnect! }
17
+ c.on_worker_boot { ActiveRecord::Base.establish_connection }
21
18
  end
22
19
  end
23
20
  end
24
21
 
25
- VERSION = "1.0.0"
22
+ VERSION = "1.1.0"
26
23
  end
@@ -21,8 +21,8 @@ Gem::Specification.new do |spec|
21
21
  spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
22
22
  spec.require_paths = ["lib"]
23
23
 
24
- spec.add_runtime_dependency "puma", "~> 3.0"
24
+ spec.add_runtime_dependency "puma", ">= 3.0", "< 5.0"
25
25
 
26
- spec.add_development_dependency "bundler", "~> 1.11"
27
- spec.add_development_dependency "rake", "~> 10.0"
26
+ spec.add_development_dependency "bundler"
27
+ spec.add_development_dependency "rake"
28
28
  end
metadata CHANGED
@@ -1,57 +1,63 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: puma-heroku
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Evan Phoenix
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-02-25 00:00:00.000000000 Z
11
+ date: 2019-09-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: puma
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
19
  version: '3.0'
20
+ - - "<"
21
+ - !ruby/object:Gem::Version
22
+ version: '5.0'
20
23
  type: :runtime
21
24
  prerelease: false
22
25
  version_requirements: !ruby/object:Gem::Requirement
23
26
  requirements:
24
- - - "~>"
27
+ - - ">="
25
28
  - !ruby/object:Gem::Version
26
29
  version: '3.0'
30
+ - - "<"
31
+ - !ruby/object:Gem::Version
32
+ version: '5.0'
27
33
  - !ruby/object:Gem::Dependency
28
34
  name: bundler
29
35
  requirement: !ruby/object:Gem::Requirement
30
36
  requirements:
31
- - - "~>"
37
+ - - ">="
32
38
  - !ruby/object:Gem::Version
33
- version: '1.11'
39
+ version: '0'
34
40
  type: :development
35
41
  prerelease: false
36
42
  version_requirements: !ruby/object:Gem::Requirement
37
43
  requirements:
38
- - - "~>"
44
+ - - ">="
39
45
  - !ruby/object:Gem::Version
40
- version: '1.11'
46
+ version: '0'
41
47
  - !ruby/object:Gem::Dependency
42
48
  name: rake
43
49
  requirement: !ruby/object:Gem::Requirement
44
50
  requirements:
45
- - - "~>"
51
+ - - ">="
46
52
  - !ruby/object:Gem::Version
47
- version: '10.0'
53
+ version: '0'
48
54
  type: :development
49
55
  prerelease: false
50
56
  version_requirements: !ruby/object:Gem::Requirement
51
57
  requirements:
52
- - - "~>"
58
+ - - ">="
53
59
  - !ruby/object:Gem::Version
54
- version: '10.0'
60
+ version: '0'
55
61
  description: A Puma plugin that contains the default Heroku config
56
62
  email:
57
63
  - evan@phx.io
@@ -60,7 +66,6 @@ extensions: []
60
66
  extra_rdoc_files: []
61
67
  files:
62
68
  - ".gitignore"
63
- - ".travis.yml"
64
69
  - Gemfile
65
70
  - LICENSE.txt
66
71
  - README.md
@@ -86,10 +91,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
86
91
  - !ruby/object:Gem::Version
87
92
  version: '0'
88
93
  requirements: []
89
- rubyforge_project:
90
- rubygems_version: 2.5.1
94
+ rubygems_version: 3.0.3
91
95
  signing_key:
92
96
  specification_version: 4
93
97
  summary: Puma integration for Heroku
94
98
  test_files: []
95
- has_rdoc:
@@ -1,4 +0,0 @@
1
- language: ruby
2
- rvm:
3
- - 2.3.0
4
- before_install: gem install bundler -v 1.11.2