Skip to content

Commit f251bb0

Browse files
committed
Merge pull request #224 from quixoten/clean_shutdown
Clean shutdown
2 parents dbf700a + 4aa9f04 commit f251bb0

2 files changed

Lines changed: 7 additions & 4 deletions

File tree

lib/protobuf/cli.rb

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,6 @@ def shutdown_server
219219
logger.info { 'RPC Server shutting down...' }
220220
@runner.try(:stop)
221221
::Protobuf::Rpc::ServiceDirectory.instance.stop
222-
logger.info { 'Shutdown complete' }
223222
end
224223

225224
# Start the runner and log the relevant options.
@@ -233,6 +232,10 @@ def start_server
233232

234233
::ActiveSupport::Notifications.instrument("after_server_bind")
235234
end
235+
236+
logger.info { 'Shutdown complete' }
237+
238+
exit 0
236239
end
237240
end
238241
end

lib/protobuf/rpc/servers/zmq/broker.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ def run
2929
rc = @poller.poll(500)
3030

3131
# The server was shutdown and no requests are pending
32-
break if rc == 0 && !running?
32+
break if rc == 0 && !running? && @server.workers.empty?
3333
# Something went wrong
3434
break if rc == -1
3535

@@ -42,7 +42,7 @@ def run
4242
end
4343

4444
def running?
45-
@server.running? || @server.workers.any?
45+
@server.running?
4646
end
4747

4848
private
@@ -113,7 +113,7 @@ def inproc?
113113
end
114114

115115
def local_queue_available?
116-
local_queue.size < local_queue_max_size
116+
local_queue.size < local_queue_max_size && running?
117117
end
118118

119119
def local_queue_max_size

0 commit comments

Comments
 (0)