Navigation Menu

Skip to content

Commit

Permalink
Output "done" trace log after graceful operations are finished
Browse files Browse the repository at this point in the history
  • Loading branch information
piroor committed Apr 23, 2015
1 parent 4fa8140 commit 6b27b72
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 5 deletions.
8 changes: 5 additions & 3 deletions lib/droonga/dispatcher.rb
Expand Up @@ -72,16 +72,18 @@ def start
@farm.start
end

def stop_gracefully(&on_stop)
def stop_gracefully(&block)
logger.trace("stop_gracefully: start")
@collector_runners.each_value do |collector_runner|
collector_runner.shutdown
end
@adapter_runners.each_value do |adapter_runner|
adapter_runner.shutdown
end
@farm.stop_gracefully(&on_stop)
logger.trace("stop_gracefully: done")
@farm.stop_gracefully do
yield
logger.trace("stop_gracefully: done")
end
end

def stop_immediately
Expand Down
2 changes: 1 addition & 1 deletion lib/droonga/engine.rb
Expand Up @@ -84,8 +84,8 @@ def stop_gracefully
@dispatcher.stop_gracefully do
@state.shutdown
yield
logger.trace("stop_gracefully/on_finish: done")
end
logger.trace("stop_gracefully/on_finish: done")
end
if @state.have_session?
logger.trace("stop_gracefully/having sessions")
Expand Down
10 changes: 10 additions & 0 deletions lib/droonga/farm.rb
Expand Up @@ -15,11 +15,13 @@
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA

require "droonga/loggable"
require "droonga/deferrable"
require "droonga/slice"

module Droonga
class Farm
include Loggable
include Deferrable

class NoSlice < StandardError
Expand Down Expand Up @@ -65,9 +67,11 @@ def start
end

def stop_gracefully
logger.trace("stop_gracefully: start")
n_slices = @slices.size
if n_slices.zero?
yield if block_given?
logger.trace("stop_gracefully: done")
return
end

Expand All @@ -77,6 +81,7 @@ def stop_gracefully
n_done_slices += 1
if n_done_slices == n_slices
yield if block_given?
logger.trace("stop_gracefully: done")
end
end
end
Expand All @@ -100,5 +105,10 @@ def process(slice_name, message)
end
@slices[slice_name].process(message)
end

private
def log_tag
"farm"
end
end
end
2 changes: 1 addition & 1 deletion lib/droonga/slice.rb
Expand Up @@ -50,6 +50,7 @@ def stop_gracefully
@job_pusher.shutdown
@processor.shutdown
yield if block_given?
logger.trace("stop_gracefully: done")
end
if @supervisor
@supervisor.stop_gracefully do
Expand All @@ -58,7 +59,6 @@ def stop_gracefully
else
on_stop.call
end
logger.trace("stop_gracefully: done")
end

def stop_immediately
Expand Down

0 comments on commit 6b27b72

Please sign in to comment.