[Groonga-commit] groonga/groonga-query-log at 8d79c2d [master] check-crash: show not finished processes

Back to archive index

Kouhei Sutou null+****@clear*****
Fri Aug 10 11:36:06 JST 2018


Kouhei Sutou	2018-08-10 11:36:06 +0900 (Fri, 10 Aug 2018)

  New Revision: 8d79c2d9794fd67d5a03b9c6ca0acbdfc6f4f686
  https://github.com/groonga/groonga-query-log/commit/8d79c2d9794fd67d5a03b9c6ca0acbdfc6f4f686

  Message:
    check-crash: show not finished processes

  Modified files:
    lib/groonga-query-log/command/check-crash.rb

  Modified: lib/groonga-query-log/command/check-crash.rb (+24 -1)
===================================================================
--- lib/groonga-query-log/command/check-crash.rb    2018-07-30 17:02:06 +0900 (5fe7276)
+++ lib/groonga-query-log/command/check-crash.rb    2018-08-10 11:36:06 +0900 (0772ef8)
@@ -77,6 +77,7 @@ module GroongaQueryLog
         attr_accessor :last_time
         attr_accessor :n_leaks
         attr_writer :crashed
+        attr_writer :finished
         attr_reader :important_entries
         def initialize(pid, start_time, log_path)
           @pid = pid
@@ -85,12 +86,24 @@ module GroongaQueryLog
           @log_path = log_path
           @n_leaks = 0
           @crashed = false
+          @finished = false
           @important_entries = []
         end
 
         def crashed?
           @crashed
         end
+
+        def finished?
+          @finished
+        end
+
+        def successfully_finished?
+          return false if crashed?
+          return false unless finished?
+
+          true
+        end
       end
 
       class Checker
@@ -109,6 +122,13 @@ module GroongaQueryLog
                  process.log_path]
             end
 
+            unless process.finished?
+              p [:unfinished,
+                 process.start_time.iso8601,
+                 process.pid,
+                 process.log_path]
+            end
+
             unless process.important_entries.empty?
               puts("Important entries:")
               process.important_entries.each_with_index do |entry, i|
@@ -125,7 +145,7 @@ module GroongaQueryLog
                  process.log_path]
             end
 
-            next unless process.crashed?
+            next unless process.successfully_finished?
 
             start = process.start_time
             last = process.last_time
@@ -229,6 +249,7 @@ module GroongaQueryLog
           when /\Agrn_init:/, /\Amroonga \d+\.\d+ started\.\z/
             process = @running_processes[entry.pid]
             if process
+              process.finished = true
               process.crashed = true
               yield(process)
               @running_processes.delete(entry.pid)
@@ -239,6 +260,7 @@ module GroongaQueryLog
             n_leaks = $1.to_i
             process = @running_processes[entry.pid]
             process.n_leaks = n_leaks
+            process.finished = true
             yield(process)
             @running_processes.delete(entry.pid)
           else
@@ -253,6 +275,7 @@ module GroongaQueryLog
             case entry.message
             when "-- CRASHED!!! --"
               process.crashed = true
+              process.finished = true
             when "----------------"
               if process.crashed?
                 yield(process)
-------------- next part --------------
HTML����������������������������...
URL: https://lists.osdn.me/mailman/archives/groonga-commit/attachments/20180810/acb1adb7/attachment-0001.htm 



More information about the Groonga-commit mailing list
Back to archive index