griffin 0.2.2 → 0.2.3

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
  SHA256:
3
- metadata.gz: 2d7b2f3dcac9c02956616faade9a47f0df671b7f0f2dd8e2c06e3bfcd7de8ff2
4
- data.tar.gz: 5ed1d0fb576d07f41ec432fa291ba366252d3194d3ebb9a4218ee2f399f4ad3d
3
+ metadata.gz: 88012127751815ee208777e0b26726b32941c06f312d4cadc0ccbf4f58a4c645
4
+ data.tar.gz: 312eb9afccef8d2edc0f42d57fca716bcccaf3166c6f72dfb37ebc632d212ed7
5
5
  SHA512:
6
- metadata.gz: 0fde56dc4c8f8e650162554cdbbf1006e45ee9918679db86a768e46db387aac3af5ba2ea2709d77c168eff34dd87dee272bd86cdc8680542b9698d58033e60b2
7
- data.tar.gz: d26aa6c934581fc68037b8419c21e2f00032f4ad79a46a226b010ebf2e236d33cbe7b28ffafe8fb4f04588a017066923869eb8f6e8a9a034714a1dbd2df007e8
6
+ metadata.gz: 48d451452794366756fb8f9ea13f2ce5c1f08c07ee8b11b2477ff4934b11cf7c2a84b98859594836e0f348bfbefc8bc9d1437fd9c73bd0f4539d0a6c844f50af
7
+ data.tar.gz: 14b127ce13955d3a354856693299ee93e1d390988f73d96c1b8b2a00cd2a29c4578f8c003392ded533fc6450c43d914533eec85e94bd12cdeaee3a7618dc060d
@@ -28,6 +28,6 @@ Gem::Specification.new do |spec|
28
28
  spec.add_development_dependency 'rspec'
29
29
  spec.add_development_dependency 'rubocop'
30
30
 
31
- spec.add_dependency 'grpc_kit', '>= 0.3.4'
31
+ spec.add_dependency 'grpc_kit', '>= 0.3.6'
32
32
  spec.add_dependency 'serverengine', '~> 2.0.7'
33
33
  end
@@ -19,12 +19,36 @@ module Griffin
19
19
  @lsock.close if @lsock
20
20
  end
21
21
 
22
- def stop
23
- server.core.shutdown
22
+ def stop(signal = nil)
23
+ kind = case signal
24
+ when ServerEngine::Signals::GRACEFUL_STOP then Griffin::Server::GRACEFUL_SHUTDOWN
25
+ when ServerEngine::Signals::IMMEDIATE_STOP then Griffin::Server::FORCE_SHUTDOWN
26
+ when ServerEngine::Signals::GRACEFUL_RESTART then Griffin::Server::GRACEFUL_RESTART
27
+ else Griffin::Server::GRACEFUL_SHUTDOWN
28
+ end
29
+ server.core.shutdown(kind)
24
30
  end
25
31
 
26
- # def after_fork; end
27
- # def reload; end
32
+ # Overwrite to identify the kind of signal in #stop
33
+ # https://github.com/treasure-data/serverengine/blob/a005f3535affaa5b15d1e66486d9349443398dd2/lib/serverengine/worker.rb#L61-L78
34
+ def install_signal_handlers
35
+ w = self
36
+ ServerEngine::SignalThread.new do |st|
37
+ st.trap(ServerEngine::Signals::GRACEFUL_STOP) { |s| w.stop(s) }
38
+ st.trap(ServerEngine::Signals::IMMEDIATE_STOP, 'SIG_DFL')
39
+
40
+ st.trap(ServerEngine::Signals::GRACEFUL_RESTART) { |s| w.stop(s) }
41
+ st.trap(ServerEngine::Signals::IMMEDIATE_RESTART, 'SIG_DFL')
42
+
43
+ st.trap(ServerEngine::Signals::RELOAD) {
44
+ w.logger.reopen!
45
+ w.reload
46
+ }
47
+ st.trap(ServerEngine::Signals::DETACH) { |s| w.stop(s) }
48
+
49
+ st.trap(ServerEngine::Signals::DUMP) { w.dump }
50
+ end
51
+ end
28
52
  end
29
53
  end
30
54
  end
@@ -12,6 +12,7 @@ module Griffin
12
12
 
13
13
  GRACEFUL_SHUTDOWN = '0'
14
14
  FORCIBLE_SHUTDOWN = '1'
15
+ GRACEFUL_RESTART = '2'
15
16
 
16
17
  class << self
17
18
  # @param bind [String]
@@ -131,6 +132,13 @@ module Griffin
131
132
  @status = :stop
132
133
  @server.graceful_shutdown
133
134
  true
135
+ when GRACEFUL_RESTART
136
+ Griffin.logger.info("Restart sever(id=#{@worker_id}) gracefully...")
137
+
138
+ @status = :restart
139
+ # timeout is false since we don't know when all connections are closed by clients.
140
+ @server.graceful_shutdown(timeout: false)
141
+ true
134
142
  end
135
143
  end
136
144
  end
@@ -67,6 +67,7 @@ module Griffin
67
67
  @opts[:min_connection_size] = Integer(min)
68
68
  @opts[:max_connection_size] = Integer(max)
69
69
  end
70
+
70
71
  def interceptors(*value)
71
72
  @opts[:interceptors].concat(value).flatten!
72
73
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Griffin
4
- VERSION = '0.2.2'
4
+ VERSION = '0.2.3'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: griffin
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 0.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yuta Iwama
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-02-04 00:00:00.000000000 Z
11
+ date: 2019-02-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -86,14 +86,14 @@ dependencies:
86
86
  requirements:
87
87
  - - ">="
88
88
  - !ruby/object:Gem::Version
89
- version: 0.3.4
89
+ version: 0.3.6
90
90
  type: :runtime
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
94
  - - ">="
95
95
  - !ruby/object:Gem::Version
96
- version: 0.3.4
96
+ version: 0.3.6
97
97
  - !ruby/object:Gem::Dependency
98
98
  name: serverengine
99
99
  requirement: !ruby/object:Gem::Requirement