stalin 0.1.1 → 0.1.2

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: 358441ddd27f1ebef84ad030bb8ac3569a1aabd2
4
- data.tar.gz: eb50ee94465f7eac9a4c7248317cee70696f21b3
3
+ metadata.gz: d3aba1948f1211ea981734cb7eb62d1326536b0b
4
+ data.tar.gz: 694df9a4c8732561d328a26ce17f64fa12eec669
5
5
  SHA512:
6
- metadata.gz: cdb30d3fd48d13301330d0c895715e1d2087c1e63e2464935ca6c30d44fdce7351229232ad058bfb40e6cbd6b6fec125376c5256e3626c3f0f7cd96b8ac221c3
7
- data.tar.gz: 26833e130901894f3be8a49631834eeffcb8e0e209db566d238f6a1b05785aaf5d1c5c34a3d8f2232a008b9f49f632878adbffd314822a59eb8a4b8e2365c470
6
+ metadata.gz: 6b922bd545a388a1457220caa2fe3d308d82401b59a25e01b667db3810263a8019fb304a80c3031cb66a298928e57b33aa07c2d147ce64cfc77d5cb668d9085b
7
+ data.tar.gz: fc6067a0ada40c95060d978c6615b9d0054ea2abc37a0062a54b91be2367f3ac6bae06c073166b1c2715f59e8e0200ab23b03d30836bb35170b04e3461791b0a
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.1
1
+ 0.1.2
@@ -1,6 +1,8 @@
1
1
  module Stalin::Adapter
2
- # A Stalin adapter that is suitable for use in Puma worker processes. Puma uses SIGTERM
3
- # to initiate orderly shutdown and seems to respond to SIGQUIT with an abrupt shutdown.
2
+ # A Stalin adapter that is suitable for use in Puma worker processes. Puma has two
3
+ # execution models.
4
+ # - "Cluster" spawns N worker processes; each responds to SIGTERM with graceful shutdown and SIGQUIT with abrupt shutdown
5
+ # - "Single" runs a server in the one-and-only master process; it responds to SIGUSR2 with graceflu restart
4
6
  class Puma < Rack
5
7
  # Create a middleware instance.
6
8
  #
@@ -10,17 +12,19 @@ module Stalin::Adapter
10
12
  # @param [Integer] cycle how frequently to check memory consumption (# requests)
11
13
  # @param [Boolean] verbose log extra information
12
14
  def initialize(app, min=1024**3, max=2*1024**3, cycle=16, verbose=false)
15
+ # Puma has no singletons, so we need to grab a reference to its CLI object.
16
+ # The CLI will not exist if puma was invoked through rackup.
17
+ #
18
+ # Since the master forks its workers, the CLI object also exists in workers.
19
+ # By the time this code runs, we'll always be in a worker.
13
20
  cli = nil
14
- ObjectSpace.each_object(::Puma::CLI) { |o| cli = o }
21
+ ObjectSpace.each_object(::Puma::CLI) { |o| cli = o } if defined?(::Puma::CLI)
15
22
 
16
- raise RuntimeError, "Puma does not appear to be active; no instances of Puma::CLI reside in memory" unless cli
17
-
18
- if cli.clustered? && cli.options[:workers] > 0
19
- # We're clustered, so workers can SIGTERM themselves to cause a restart
23
+ if cli && cli.clustered? && cli.options[:workers] > 0
24
+ # Multiprocess model: send ourselves SIGTERM
20
25
  super(app, :TERM, :QUIT, min, max, cycle, verbose)
21
26
  else
22
- # We're running in single mode; our one-and-only process must USR2 to restart
23
- # itself
27
+ # Single-process model ("rackup," or "puma -w 0")
24
28
  super(app, :USR2, :USR1, min, max, cycle, verbose)
25
29
  end
26
30
  end
data/stalin.gemspec CHANGED
@@ -2,16 +2,14 @@
2
2
  # DO NOT EDIT THIS FILE DIRECTLY
3
3
  # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
4
  # -*- encoding: utf-8 -*-
5
- # stub: stalin 0.1.0 ruby lib
6
5
 
7
6
  Gem::Specification.new do |s|
8
7
  s.name = "stalin"
9
- s.version = "0.1.0"
8
+ s.version = "0.1.2"
10
9
 
11
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
12
- s.require_paths = ["lib"]
13
11
  s.authors = ["Tony Spataro"]
14
- s.date = "2015-04-17"
12
+ s.date = "2015-04-21"
15
13
  s.description = "Kill Web application workers based on arbitrary conditions."
16
14
  s.email = "xeger@xeger.net"
17
15
  s.extra_rdoc_files = [
@@ -38,7 +36,8 @@ Gem::Specification.new do |s|
38
36
  ]
39
37
  s.homepage = "https://github.com/xeger/stalin"
40
38
  s.licenses = ["MIT"]
41
- s.rubygems_version = "2.2.2"
39
+ s.require_paths = ["lib"]
40
+ s.rubygems_version = "2.0.14"
42
41
  s.summary = "Kill rack"
43
42
 
44
43
  if s.respond_to? :specification_version then
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: stalin
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tony Spataro
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-04-17 00:00:00.000000000 Z
11
+ date: 2015-04-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: jeweler