Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Updating riddle

  • Loading branch information...
commit 6cb96a41629d20c67bfb9b32e37de0fe86a23147 1 parent 2079b0d
@pat pat authored
View
2  vendor/riddle/lib/riddle.rb
@@ -18,7 +18,7 @@ module Version #:nodoc:
Rev = 1533
# Release number to mark my own fixes, beyond feature parity with
# Sphinx itself.
- Release = 7
+ Release = 10
String = [Major, Minor, Tiny].join('.')
GemVersion = [Major, Minor, Tiny, Rev, Release].join('.')
View
19 vendor/riddle/lib/riddle/client.rb
@@ -405,7 +405,7 @@ def connect(&block)
"Connection to #{@server} on #{@port} timed out after #{@timeout} seconds"
end
end
-
+
begin
yield socket
ensure
@@ -414,8 +414,8 @@ def connect(&block)
end
def initialise_connection
- socket = TCPSocket.new @server, @port
-
+ socket = initialise_socket
+
# Checking version
version = socket.recv(4).unpack('N*').first
if version < 1
@@ -429,6 +429,19 @@ def initialise_connection
socket
end
+ def initialise_socket
+ tries = 0
+ begin
+ socket = TCPSocket.new @server, @port
+ rescue Errno::ECONNREFUSED => e
+ retry if (tries += 1) < 5
+ raise Riddle::ConnectionError,
+ "Connection to #{@server} on #{@port} failed. #{e.message}"
+ end
+
+ socket
+ end
+
# Send a collection of messages, for a command type (eg, search, excerpts,
# update), to the Sphinx daemon.
def request(command, messages)
View
19 vendor/riddle/lib/riddle/controller.rb
@@ -4,38 +4,38 @@ def initialize(configuration, path)
@configuration = configuration
@path = path
end
-
+
def index
cmd = "indexer --config #{@path} --all"
cmd << " --rotate" if running?
`#{cmd}`
end
-
+
def start
return if running?
-
+
cmd = "searchd --pidfile --config #{@path}"
-
+
if RUBY_PLATFORM =~ /mswin/
system("start /B #{cmd} 1> NUL 2>&1")
else
`#{cmd}`
end
-
+
sleep(1)
-
+
unless running?
puts "Failed to start searchd daemon. Check #{@configuration.searchd.log}."
end
end
-
+
def stop
return unless running?
Process.kill('SIGTERM', pid.to_i)
rescue Errno::EINVAL
Process.kill('SIGKILL', pid.to_i)
end
-
+
def pid
if File.exists?(@configuration.searchd.pid_file)
File.read(@configuration.searchd.pid_file)[/\d+/]
@@ -43,12 +43,11 @@ def pid
nil
end
end
-
+
def running?
!!pid && !!Process.kill(0, pid.to_i)
rescue
false
end
-
end
end

0 comments on commit 6cb96a4

Please sign in to comment.
Something went wrong with that request. Please try again.