lib/multi_process/process/rails.rb in multi_process-0.4.0 vs lib/multi_process/process/rails.rb in multi_process-0.5.0
- old
+ new
@@ -1,17 +1,15 @@
class MultiProcess::Process
-
# Provides functionality for a process that is a rails server
# process.
#
# Include this module if required.
#
# Functions include port generation, default server command and
# availability check based on if server socket is reachable.
#
module Rails
-
# Server wrapper given as argument to `server` action.
#
attr_reader :server
# Port server should be running on.
@@ -42,11 +40,11 @@
def port
@port ||= free_port
end
def available?
- raise ArgumentError.new "Cannot check availability for port #{port}." if port == 0
+ fail ArgumentError.new "Cannot check availability for port #{port}." if port == 0
TCPSocket.new('127.0.0.1', port).close
true
rescue Errno::ECONNREFUSED, Errno::EHOSTUNREACH
false
@@ -67,10 +65,10 @@
private
def free_port
socket = Socket.new(:INET, :STREAM, 0)
- socket.bind(Addrinfo.tcp("127.0.0.1", 0))
+ socket.bind(Addrinfo.tcp('127.0.0.1', 0))
socket.local_address.ip_port
ensure
socket.close if socket
end
end