[Groonga-commit] droonga/droonga-engine at b0d37b8 [master] Extract command to check the droonga-engine service is running or not

Back to archive index

YUKI Hiroshi null+****@clear*****
Thu Sep 18 11:22:44 JST 2014


YUKI Hiroshi	2014-09-18 11:22:44 +0900 (Thu, 18 Sep 2014)

  New Revision: b0d37b81e9b25d314a3f95ffc9089ea4723d3a62
  https://github.com/droonga/droonga-engine/commit/b0d37b81e9b25d314a3f95ffc9089ea4723d3a62

  Message:
    Extract command to check the droonga-engine service is running or not

  Copied files:
    bin/droonga-engine-status
      (from bin/droonga-engine-stop)
  Modified files:
    bin/droonga-engine-stop

  Copied: bin/droonga-engine-status (+1 -3) 96%
===================================================================
--- bin/droonga-engine-stop    2014-09-18 11:12:58 +0900 (1d2c8a7)
+++ bin/droonga-engine-status    2014-09-18 11:22:44 +0900 (68a2dbc)
@@ -53,9 +53,7 @@ begin
     raise Failed.new("Not a droonga-engine process: PID <#{pid}> (#{process_info.cmdline})")
   end
 
-  puts "Sending SIGTERM to the process...";
-  Process.kill(:TERM, pid)
-
+  puts "droonga-engine is running.";
 rescue Failed => error
   puts "Failed to detect running droonga-engine process."
   puts error.message

  Modified: bin/droonga-engine-stop (+7 -37)
===================================================================
--- bin/droonga-engine-stop    2014-09-18 11:12:58 +0900 (1d2c8a7)
+++ bin/droonga-engine-stop    2014-09-18 11:22:44 +0900 (4ed4b1b)
@@ -20,46 +20,16 @@ require "sys/proctable"
 
 require "droonga/command/droonga_engine"
 
+running = system("droonga-engine-status", *ARGV)
+exit(false) unless running
+
 configuration = Droonga::Command::DroongaEngine::Configuration.new
 parser = OptionParser.new
 configuration.add_command_line_options(parser)
 parser.parse!(ARGV)
 
-class Failed < StandardError
-  attr_reader :message
-
-  def initialize(message)
-    @message = message
-  end
-end
-
-begin
-  pid_file = configuration.pid_file_path
-  unless pid_file.exist?
-    raise Failed.new("There is no PID file at <#{pid_file.to_s}>.")
-  end
-
-  pid = File.read(pid_file).strip
-  unless pid =~ /\A[1-9][0-9]*\z/
-    raise Failed.new("Invalid PID <#{pid}>.")
-  end
-
-  pid = pid.to_i
-  process_info = Sys::ProcTable.ps(pid)
-  unless process_info
-    raise Failed.new("No such process with the PID <#{pid}>.")
-  end
-  unless process_info.cmdline.include?("droonga-engine")
-    raise Failed.new("Not a droonga-engine process: PID <#{pid}> (#{process_info.cmdline})")
-  end
-
-  puts "Sending SIGTERM to the process...";
-  Process.kill(:TERM, pid)
-
-rescue Failed => error
-  puts "Failed to detect running droonga-engine process."
-  puts error.message
-  exit(false)
-end
-
+pid_file = configuration.pid_file_path
+pid = File.read(pid_file).strip
+puts "Sending SIGTERM to the process...";
+Process.kill(:TERM, pid.to_i)
 exit(true)
-------------- next part --------------
HTML����������������������������...
Download 



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