putting some load on postgres, but not yet with the EventMachine postgresql adapter

This commit is contained in:
Dan Buch 2012-06-16 13:44:22 -04:00
parent d67d1632a8
commit 5927b05f6c
2 changed files with 10 additions and 16 deletions

View File

@ -13,7 +13,7 @@ loop do
end end
successes += 1 successes += 1
backoff = 0.5 backoff = 0.5
sleep 0.01 sleep 0.01 if ENV['SLEEP']
rescue rescue
STDOUT.write('E') STDOUT.write('E')
STDOUT.flush STDOUT.flush

View File

@ -1,22 +1,16 @@
require 'logger'
require 'eventmachine' require 'eventmachine'
require 'sequel' require 'sequel'
if ENV['MPDB'] DB = Sequel.connect("postgres://#{ENV['USER']}@localhost/marco_polo",
DB = Sequel.connect(ENV['MPDB']) :max_connections => 10)
else DB.create_table! :locations do
DB = Sequel.connect('sqlite://marco-polo.sqlite3')
end
begin
DB[:locations].empty?
rescue Sequel::DatabaseError
DB.create_table(:locations) do
primary_key :id primary_key :id
String :client String :client
Integer :x Integer :x
Integer :y Integer :y
end end
end
module MarcoPoloServer module MarcoPoloServer
def post_init def post_init