[Groonga-commit] droonga/droonga-engine at 3ebaca0 [master] Use system Serf if it exists

Back to archive index

Kouhei Sutou null+****@clear*****
Thu May 22 12:49:45 JST 2014


Kouhei Sutou	2014-05-22 12:49:45 +0900 (Thu, 22 May 2014)

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

  Message:
    Use system Serf if it exists

  Modified files:
    lib/droonga/serf.rb

  Modified: lib/droonga/serf.rb (+15 -2)
===================================================================
--- lib/droonga/serf.rb    2014-05-22 12:41:43 +0900 (05db25f)
+++ lib/droonga/serf.rb    2014-05-22 12:49:45 +0900 (5512377)
@@ -36,7 +36,7 @@ module Droonga
     def start
       logger.trace("start: start")
       ensure_serf
-      ENV["SERF"] = self.class.path.to_s
+      ENV["SERF"] = @serf
       ENV["SERF_RPC_ADDRESS"] = rpc_address
       retry_joins = []
       detect_other_hosts.each do |other_host|
@@ -59,14 +59,27 @@ module Droonga
 
     private
     def ensure_serf
+      @serf = find_system_serf
+      return if @serf
+
       serf_path = self.class.path
+      @serf = serf_path.to_s
       return if serf_path.executable?
       downloader = SerfDownloader.new(serf_path)
       downloader.download
     end
 
+    def find_system_serf
+      paths = (ENV["PATH"] || "").split(File::PATH_SEPARATOR)
+      paths.each do |path|
+        serf = File.join(path, "serf")
+        return serf if File.executable?(serf)
+      end
+      nil
+    end
+
     def run(command, *options)
-      spawn(self.class.path.to_s, command, "-rpc-addr", rpc_address, *options)
+      spawn(@serf, command, "-rpc-addr", rpc_address, *options)
     end
 
     def extract_host(node_name)
-------------- next part --------------
HTML����������������������������...
Télécharger 



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