unicorn-worker-killer 0.3.4 → 0.3.5

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8e9021aa4840a7f7ad56c19a11bd0af9831950cc
4
- data.tar.gz: 2e1efded731931d091ec2af81b21a50d2d718f7d
3
+ metadata.gz: a62e19d2cacf4fa0c1156246c9b045b7c9a9910d
4
+ data.tar.gz: 4c15e610631cac77d7e96221f071f2fb441efcb1
5
5
  SHA512:
6
- metadata.gz: 97876ad6dc0067f64786630caeba653ab33789d3522c62c3e623627e6266336572aef812a30a9e532cd139f298c9f4ef2aacb8357bf1c13662edaee43f26007f
7
- data.tar.gz: be739847d6a972f223631216f67f14082c5fddf6a603808285db688b8a8d58e524925949bf11fd940b9c18385b7915599af8ef7ba15a76f7a06f010e4803bb9c
6
+ metadata.gz: 2d9b47622f9b2f57e5b392b706dd3f2ef9e216bee03a5a5b908c0fc99fcff2963980568cbb36f94ad7d49f7006c5f971dd38fb481b76b8a10eb109c5c3041740
7
+ data.tar.gz: 1822892d9f269ee1f9c524b1326f972876c5f44e1e6f646189020dcf8ab7ee9406fa02c933dad1930f21e0eb3b175854d9372b633bb2e469bda00b7d7b1cc6f3
data/ChangeLog CHANGED
@@ -1,3 +1,7 @@
1
+ Release 0.3.5 - 2013/03/08
2
+ * configurable max QUIT, TERM, and sleep interval
3
+ * fix warning message of signal handling
4
+
1
5
  Release 0.3.4 - 2013/03/08
2
6
  * try SIGQUIT first, rather than SIGTERM
3
7
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.3.4
1
+ 0.3.5
@@ -0,0 +1,11 @@
1
+ module Unicorn::WorkerKiller
2
+ class Configuration
3
+ attr_accessor :max_quit, :max_term, :sleep_interval
4
+
5
+ def initialize
6
+ self.max_quit = 10
7
+ self.max_term = 15
8
+ self.sleep_interval = 1
9
+ end
10
+ end
11
+ end
@@ -1,7 +1,10 @@
1
+ require 'unicorn/configuration'
2
+
1
3
  module Unicorn::WorkerKiller
2
4
  # Self-destruction by sending the signals to myself. The process sometimes
3
- # doesn't terminate by SIGTERM, so this tries to send SIGQUIT and SIGKILL
5
+ # doesn't terminate by SIGQUIT, so this tries to send SIGTERM and SIGKILL
4
6
  # if it doesn't finish immediately.
7
+ # @see http://unicorn.bogomips.org/SIGNALS.html
5
8
  def self.kill_self(logger, start_time)
6
9
  alive_sec = (Time.now - start_time).to_i
7
10
 
@@ -9,16 +12,16 @@ module Unicorn::WorkerKiller
9
12
  while true
10
13
  i += 1
11
14
  sig = :QUIT
12
- if i > 10 # TODO configurable QUIT MAX
15
+ if i > configuration.max_quit
13
16
  sig = :TERM
14
- elsif i > 15 # TODO configurable TERM MAX
17
+ elsif i > configuration.max_term
15
18
  sig = :KILL
16
19
  end
17
20
 
18
- logger.warn "#{self} send SIGTERM (pid: #{Process.pid}) alive: #{alive_sec} sec (trial #{i})"
21
+ logger.warn "#{self} send SIG#{sig} (pid: #{Process.pid}) alive: #{alive_sec} sec (trial #{i})"
19
22
  Process.kill sig, Process.pid
20
23
 
21
- sleep 1 # TODO configurable sleep
24
+ sleep configuration.sleep_interval
22
25
  end
23
26
  end
24
27
 
@@ -120,4 +123,13 @@ module Unicorn::WorkerKiller
120
123
  end
121
124
  end
122
125
  end
126
+
127
+ def self.configure
128
+ self.configuration ||= Configuration.new
129
+ yield(configuration) if block_given?
130
+ end
131
+
132
+ class << self
133
+ attr_accessor :configuration
134
+ end
123
135
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: unicorn-worker-killer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.4
4
+ version: 0.3.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kazuki Ohta
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-03-07 00:00:00.000000000 Z
12
+ date: 2013-03-08 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: unicorn
@@ -54,6 +54,7 @@ files:
54
54
  - README.md
55
55
  - Rakefile
56
56
  - VERSION
57
+ - lib/unicorn/configuration.rb
57
58
  - lib/unicorn/worker_killer.rb
58
59
  - unicorn-worker-killer.gemspec
59
60
  homepage: https://github.com/kzk/unicorn-worker-killer