Skip to content

Commit

Permalink
Merge pull request #224 from quixoten/clean_shutdown
Browse files Browse the repository at this point in the history
Clean shutdown
  • Loading branch information
liveh2o committed Oct 10, 2014
2 parents dbf700a + 4aa9f04 commit f251bb0
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
5 changes: 4 additions & 1 deletion lib/protobuf/cli.rb
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,6 @@ def shutdown_server
logger.info { 'RPC Server shutting down...' }
@runner.try(:stop)
::Protobuf::Rpc::ServiceDirectory.instance.stop
logger.info { 'Shutdown complete' }
end

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

::ActiveSupport::Notifications.instrument("after_server_bind")
end

logger.info { 'Shutdown complete' }

exit 0
end
end
end
Expand Down
6 changes: 3 additions & 3 deletions lib/protobuf/rpc/servers/zmq/broker.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def run
rc = @poller.poll(500)

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

Expand All @@ -42,7 +42,7 @@ def run
end

def running?
@server.running? || @server.workers.any?
@server.running?
end

private
Expand Down Expand Up @@ -113,7 +113,7 @@ def inproc?
end

def local_queue_available?
local_queue.size < local_queue_max_size
local_queue.size < local_queue_max_size && running?
end

def local_queue_max_size
Expand Down

0 comments on commit f251bb0

Please sign in to comment.