Skip to content

Commit

Permalink
allow for running redcar to bring an existing redcar 'to the front'
Browse files Browse the repository at this point in the history
  • Loading branch information
rdp committed Feb 16, 2010
1 parent 8a469ba commit ef007dc
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions lib/redcar.rb
Original file line number Diff line number Diff line change
Expand Up @@ -61,21 +61,19 @@ def self.environment
@environment
end

# if they are all files/dirs then attempt to load via drb if available
# attempt to load via drb if available
def self.try_to_load_via_drb
return if ARGV.include?("--multiple-instance")
return unless ARGV.any? and ARGV.all? {|arg| File.exist?(arg) }

port = 9999

port = 9999
begin
begin
TCPSocket.new('127.0.0.1', port).close
rescue Errno::ECONNREFUSED
# no other instance running...
rescue Errno::ECONNREFUSED
# no other instance is currently running...
return
end
puts 'attempting to load via drb'
puts 'attempting to start via running instance'
drb = DRbObject.new(nil, "druby://127.0.0.1:#{port}")

if ARGV.any?
Expand All @@ -87,7 +85,7 @@ def self.try_to_load_via_drb
else
return unless drb.open_item_drb('just_bring_to_front')
end
puts 'success'
puts 'Success'
true
rescue Exception => e
puts e.class.to_s + ": " + e.message
Expand Down

0 comments on commit ef007dc

Please sign in to comment.