Throwing three non-pausing clients at mysql-backed EM server
is causing intermittent port binding problems which manifest as an unreachable server. Inserting a pause on the client side fixes the problem. Hm.
This commit is contained in:
parent
8addb0fe6c
commit
d67d1632a8
@ -1,11 +1,25 @@
|
||||
require 'socket'
|
||||
|
||||
successes = 0
|
||||
backoff = 0.5
|
||||
loop do
|
||||
TCPSocket.open('127.0.0.1', 22000) do |sock|
|
||||
sock.send("sally #{rand(100)} #{rand(100)}\n", 0)
|
||||
sock.recv(100)
|
||||
sock.close
|
||||
STDOUT.write('.')
|
||||
begin
|
||||
TCPSocket.open('127.0.0.1', 22000) do |sock|
|
||||
sock.send("sally #{rand(101)} #{rand(101)}\n", 0)
|
||||
sock.recv(100)
|
||||
sock.close
|
||||
STDOUT.write('.')
|
||||
STDOUT.flush
|
||||
end
|
||||
successes += 1
|
||||
backoff = 0.5
|
||||
sleep 0.01
|
||||
rescue
|
||||
STDOUT.write('E')
|
||||
STDOUT.flush
|
||||
STDERR.write("\nmade it #{successes} times. sleeping #{backoff} secs\n")
|
||||
successes = 0
|
||||
sleep backoff
|
||||
backoff *= 2
|
||||
end
|
||||
end
|
||||
|
@ -1,10 +1,16 @@
|
||||
require 'eventmachine'
|
||||
require 'sequel'
|
||||
|
||||
DB = Sequel.connect('sqlite://marco-polo.sqlite3')
|
||||
if ENV['MPDB']
|
||||
DB = Sequel.connect(ENV['MPDB'])
|
||||
else
|
||||
DB = Sequel.connect('sqlite://marco-polo.sqlite3')
|
||||
end
|
||||
|
||||
if DB[:locations].nil?
|
||||
DB.create_table :locations do
|
||||
begin
|
||||
DB[:locations].empty?
|
||||
rescue Sequel::DatabaseError
|
||||
DB.create_table(:locations) do
|
||||
primary_key :id
|
||||
String :client
|
||||
Integer :x
|
||||
|
Loading…
Reference in New Issue
Block a user