Permalink
Browse files

Update (no new features)

  • Loading branch information...
1 parent 5d2a13a commit 2c56dbdb9b19584c5f3bc2ced20c684bd84fa46f @rhenium rhenium committed Mar 13, 2013
Showing with 292 additions and 192 deletions.
  1. +1 −0 .gitignore
  2. +1 −0 Gemfile
  3. +2 −0 Gemfile.lock
  4. +5 −4 app/helpers/application_helper.rb
  5. +10 −4 app/views/main/index.haml
  6. +3 −1 client/Gemfile
  7. +30 −1 client/Gemfile.lock
  8. +10 −0 client/start.rb
  9. +149 −157 client/worker.rb
  10. +51 −12 config/database.yml
  11. +7 −7 config/routes.rb
  12. +6 −0 lib/receiver/start.rb
  13. +17 −6 lib/receiver/worker.rb
View
1 .gitignore
@@ -24,6 +24,7 @@
# local scripts
/client/worker.sh
+/client/Procfile
/client/settings.yml
/server.sh
View
1 Gemfile
@@ -5,6 +5,7 @@ gem 'rails', '4.0.0.beta1'
gem 'mysql2'
gem 'unicorn'
+gem 'daemon-spawn', :require => 'daemon_spawn'
gem 'rails_config'
gem 'kaminari'
View
2 Gemfile.lock
@@ -43,6 +43,7 @@ GEM
coffee-script-source
execjs
coffee-script-source (1.6.1)
+ daemon-spawn (0.4.2)
em-twitter (0.2.1)
eventmachine (~> 1.0)
http_parser.rb (~> 0.5)
@@ -153,6 +154,7 @@ PLATFORMS
DEPENDENCIES
coffee-rails (~> 4.0.0.beta1)
+ daemon-spawn
em-twitter
em-work_queue
haml-rails
View
9 app/helpers/application_helper.rb
@@ -7,14 +7,15 @@ def format_tweet_created_at(dt)
def format_tweet_text(text)
text
- .gsub(/<url:((?:https?|ftp).+?):(.+?)>/){link_to($2, $1, :target => "_blank")}
- .gsub(/<hashtag:(.+?)>/){link_to("##{URI.decode($1)}", "https://twitter.com/search?q=%23#{$1}")}
- .gsub(/<mention:(.+?)>/){link_to("@#{$1}", "/#{$1}")}
+ .gsub(/<url:(.+?):(.+?)>/){link_to(CGI.unescape($2), CGI.unescape($1), :target => "_blank")}
+ .gsub(/<hashtag:(.+?)>/){link_to("##{CGI.unescape($1)}", "https://twitter.com/search?q=%23#{$1}")}
+ .gsub(/<cashtag:(.+?)>/){link_to("$#{CGI.unescape($1)}", "https://twitter.com/search?q=%23#{$1}")}
+ .gsub(/<mention:(.+?)>/){link_to("@#{CGI.unescape($1)}", "/#{$1}")}
.gsub(/\r\n|\r|\n/, "<br />")
end
def format_source_text(text)
- text.gsub("&", "&amp;")
+ format_tweet_text(text)
end
def status_url(tweet)
View
14 app/views/main/index.haml
@@ -3,21 +3,27 @@
%p
Favstar クローンです。UserStreams つかってます。
= link_to "@KOBA789", "https://twitter.com/KOBA789"
- さんにサーバーを貸していただけることになりました…!!
+ さんにサーバーを貸していただけることになりました…!!ありがとうございます!
%strong まだ開発途中段階のものですがとりあえず動いています。登録後接続まで最大30分かかります。
%strong 動作のテスト中ですので、途中で登録をうちきったりあまりにふぁぼられ・ふぁぼりが多いユーザーの登録を削除する可能性もあります。
%div
URLとかについて
%div
best:
- = link_to "(/users)/re4k", "/re4k"
+ = link_to "/cat", "/cat"
%div
recent:
- = link_to "(/users)/re4k/recent", "/re4k/recent"
+ = link_to "/cat/recent", "/cat/recent"
+ %div
+ timeline(exclude RTs):
+ = link_to "/cat/timeline", "/cat/timeline"
+ %div
+ discovery:
+ = link_to "/cat/my", "/cat/my"
%div
こんどほかのところもFavstar互換にする
%div
デザインなんとかしないと...
%div
- = link_to "@re4k", "https://twitter.com/re4k"
+ = link_to "@cat", "https://twitter.com/cat"
View
4 client/Gemfile
@@ -1,6 +1,8 @@
ruby '1.9.3'
source 'https://rubygems.org'
+gem 'foreman'
+
gem 'settingslogic'
-gem 'em-twitter'
+gem 'tweetstream'
gem 'yajl-ruby', :require => "yajl"
View
31 client/Gemfile.lock
@@ -1,20 +1,49 @@
GEM
remote: https://rubygems.org/
specs:
+ addressable (2.3.3)
+ cookiejar (0.3.0)
+ daemons (1.1.9)
+ em-http-request (1.0.3)
+ addressable (>= 2.2.3)
+ cookiejar
+ em-socksify
+ eventmachine (>= 1.0.0.beta.4)
+ http_parser.rb (>= 0.5.3)
+ em-socksify (0.2.1)
+ eventmachine (>= 1.0.0.beta.4)
em-twitter (0.2.1)
eventmachine (~> 1.0)
http_parser.rb (~> 0.5)
simple_oauth (~> 0.1)
eventmachine (1.0.3)
+ faraday (0.8.6)
+ multipart-post (~> 1.1)
+ foreman (0.62.0)
+ thor (>= 0.13.6)
http_parser.rb (0.5.3)
+ multi_json (1.6.1)
+ multipart-post (1.2.0)
settingslogic (2.0.9)
simple_oauth (0.2.0)
+ thor (0.17.0)
+ tweetstream (2.4.0)
+ daemons (~> 1.1)
+ em-http-request (~> 1.0.2)
+ em-twitter (~> 0.2)
+ twitter (~> 4.0)
+ yajl-ruby (~> 1.1)
+ twitter (4.6.0)
+ faraday (~> 0.8, < 0.10)
+ multi_json (~> 1.0)
+ simple_oauth (~> 0.2)
yajl-ruby (1.1.0)
PLATFORMS
ruby
DEPENDENCIES
- em-twitter
+ foreman
settingslogic
+ tweetstream
yajl-ruby
View
10 client/start.rb
@@ -0,0 +1,10 @@
+#!/usr/bin/env ruby
+require "./worker"
+
+$stdout.sync = true
+$stderr.sync = true
+
+worker = Worker.new
+worker.start
+
+
View
306 client/worker.rb
@@ -1,105 +1,135 @@
require "time"
-require "cgi"
-require "em-twitter"
+require "tweetstream"
require "yajl"
require "./settings"
require "./logger"
+module EM
+ class Connection
+ def send_chunk(data)
+ send_data(data + "\r\n")
+ end
+ end
+end
+
+module TweetStream
+ class Client
+ attr_reader :user_id, :row_id
+
+ def _set_aclog(user_id, row_id)
+ @user_id = user_id
+ @row_id = row_id
+ end
+ end
+end
+
class Worker
class DBProxyClient < EM::Connection
def initialize
- super
- @connections = []
+ @clients = []
@receive_buf = ""
end
- def format_text_from_hash(hash)
- text = hash[:text]
- entities = hash[:entities]
-
- return text unless entities
-
- gaps = {}
- replace = -> ents, bl do
- ents.each do |entity|
- starts = entity[:indices].first
- ends = entity[:indices].last
- rep = bl.call(entity)
- gaps[starts] = rep.size - (ends - starts)
- bgap = gaps.select{|k, v| k < starts}.values.inject(0){|s, m| s += m}
- text[starts + bgap...ends + bgap] = rep
- end
+ def format_text(status)
+ chars = status.text.to_s.split(//)
+
+ entities = status.attrs[:entities].values.flatten.map do |entity|
+ entity[:hashtag] = entity[:text] if entity[:text]
+ entity
+ end.sort_by{|entity| entity[:indices].first}
+
+ result = []
+ last_index = entities.inject(0) do |last_index, entity|
+ result << chars[last_index...entity[:indices].first]
+ result << if entity[:url]
+ "<url:#{CGI.escape(entity[:expanded_url])}:#{CGI.escape(entity[:display_url])}>"
+ elsif entity[:hashtag]
+ "<hashtag:#{CGI.escape(entity[:hashtag])}>"
+ elsif entity[:screen_name]
+ "<mention:#{CGI.escape(entity[:screen_name])}>"
+ elsif entity[:cashtag]
+ "<cashtag:#{CGI.escape(entity[:cashtag])}>"
+ end
+ entity[:indices].last
end
+ result << chars[last_index..-1]
- replace.call((entities[:media] || []) + (entities[:urls] || []),
- -> entity {"<url:#{CGI.escapeHTML(entity[:expanded_url])}:#{CGI.escapeHTML(entity[:display_url])}>"})
- replace.call(entities[:hashtags] || [],
- -> entity {"<hashtag:#{CGI.escapeHTML(URI.encode(entity[:text]))}>"})
- replace.call(entities[:user_mentions] || [],
- -> entity {"<mention:#{CGI.escapeHTML(URI.encode(entity[:screen_name]))}>"})
-
- return text
+ result.flatten.join
end
- def format_source(source)
- source
+ def format_source(status)
+ if status.source.index("<a")
+ url = status.source.scan(/href="(.+?)"/).flatten.first
+ name = status.source.scan(/>(.+?)</).flatten.first
+ "<url:#{CGI.escape(url)}:#{CGI.escape(name)}>"
+ else
+ status.source
+ end
end
- def send_user(hash)
- out = {:id => hash[:id],
- :screen_name => hash[:screen_name],
- :name => hash[:name],
- :profile_image_url => hash[:profile_image_url_https]}
- send_data("USER #{Yajl::Encoder.encode(out)}\r\n")
+ def send_user(user)
+ out = {:id => user.id,
+ :screen_name => user.screen_name,
+ :name => user.name,
+ :profile_image_url => user.profile_image_url_https}
+ send_chunk("USER #{Yajl::Encoder.encode(out)}")
end
- def send_tweet(hash)
- send_user(hash[:user])
- out = {:id => hash[:id],
- :text => format_text_from_hash(hash),
- :source => format_source(hash[:source]),
- :tweeted_at => hash[:created_at],
- :user_id => hash[:user][:id]}
- send_data("TWEET #{Yajl::Encoder.encode(out)}\r\n")
+ def send_tweet(status)
+ send_user(status.user)
+ out = {:id => status.id,
+ :text => format_text(status),
+ :source => format_source(status),
+ :tweeted_at => status.created_at,
+ :user_id => status.user.id}
+ send_chunk("TWEET #{Yajl::Encoder.encode(out)}")
+ $logger.debug("Sent Tweet: #{status.id}")
end
- def send_favorite(hash)
- send_tweet(hash[:target_object])
- send_user(hash[:source])
- out = {:tweet_id => hash[:target_object][:id],
- :user_id => hash[:source][:id]}
- send_data("FAVORITE #{Yajl::Encoder.encode(out)}\r\n")
+ def send_favorite(source, target_object)
+ send_tweet(target_object)
+ send_user(source)
+ out = {:tweet_id => target_object.id,
+ :user_id => source.id}
+ send_chunk("FAVORITE #{Yajl::Encoder.encode(out)}")
+ $logger.debug("Sent Favorite: #{source.id} => #{target_object.id}")
end
- def send_unfavorite(hash)
- send_tweet(hash[:target_object])
- send_user(hash[:source])
- out = {:tweet_id => hash[:target_object][:id],
- :user_id => hash[:source][:id]}
- send_data("UNFAVORITE #{Yajl::Encoder.encode(out)}\r\n")
+ def send_unfavorite(source, target_object)
+ send_tweet(target_object)
+ send_user(source)
+ out = {:tweet_id => target_object.id,
+ :user_id => source.id}
+ send_chunk("UNFAVORITE #{Yajl::Encoder.encode(out)}")
+ $logger.debug("Sent Unfavorite: #{source.id} => #{target_object.id}")
end
- def send_retweet(hash)
- send_tweet(hash[:retweeted_status])
- out = {:id => hash[:id],
- :tweet_id => hash[:id],
- :user_id => hash[:user][:id]}
- send_data("RETWEET #{Yajl::Encoder.encode(out)}\r\n")
+ def send_retweet(status)
+ send_tweet(status.retweeted_status)
+ out = {:id => status.id,
+ :tweet_id => status.retweeted_status.id,
+ :user_id => status.user.id}
+ send_chunk("RETWEET #{Yajl::Encoder.encode(out)}")
+ $logger.debug("Sent Retweet: #{status.user.id} => #{status.retweeted_status.id}")
end
- def send_delete(hash)
- out = {:tweet_id => hash[:delete][:status][:id],
- :user_id => hash[:delete][:status][:user_id]}
- send_data("DELETE #{Yajl::Encoder.encode(out)}\r\n")
+ def send_delete(status_id, user_id)
+ out = {:tweet_id => status_id,
+ :user_id => user_id}
+ send_chunk("DELETE #{Yajl::Encoder.encode(out)}")
+ $logger.debug("Sent Delete: #{user_id} => #{status_id}")
end
def post_init
- send_data("CONNECT #{Settings.secret_key}&#{Settings.worker_number}&#{Settings.worker_count}\r\n")
+ send_chunk("CONNECT #{Settings.secret_key}&#{Settings.worker_number}&#{Settings.worker_count}")
end
def unbind
$logger.info("Connection closed")
- reconnect(@options[:host], @options[:port])
+ EM.add_timer(5) do
+ reconnect(Settings.db_proxy_host, Settings.db_proxy_port)
+ post_init
+ end
end
def receive_data(data)
@@ -115,114 +145,75 @@ def receive_data(data)
$logger.error("Error: #{arg.last}")
when "ACCOUNT"
begin
- p arg
hash = ::Yajl::Parser.parse(arg.last, :symbolize_keys => true)
- con = EM::Twitter::Client.connect({
- :host => "userstream.twitter.com",
- :path => "/1.1/user.json",
- :oauth => {:consumer_key => Settings.consumer_key,
- :consumer_secret => Settings.consumer_secret,
- :token => hash[:oauth_token],
- :token_secret => hash[:oauth_token_secret]},
- :method => "GET",
- # user data
- :user_id => hash[:user_id]
- })
-
- con.on_reconnect do |timeout, count|
- $logger.warn("Reconnected: #{con.options[:user_id]}/#{count}")
+
+ @clients << client = TweetStream::Client.new(
+ :consumer_key => Settings.consumer_key,
+ :consumer_secret => Settings.consumer_secret,
+ :oauth_token => hash[:oauth_token],
+ :oauth_token_secret => hash[:oauth_token_secret],
+ :auth_method => :oauth)
+ client._set_aclog(hash[:user_id], hash[:id])
+
+ client.on_error do |message|
+ $logger.warn("UserStreams Error(##{client.user_id}): #{message}")
end
- con.on_max_reconnects do |timeout, count|
- $logger.error("Reached Max Reconnects: #{con.options[:user_id]}")
+ client.on_limit do |discarded_count|
+ $logger.warn("UserStreams Limit Event(##{client.user_id}): #{discarded_count}")
end
- con.on_unauthorized do
- $logger.error("Unauthorized: #{con.options[:user_id]}")
- @connections.delete(con)
- con.stop
+ client.on_unauthorized do
+ # revoked?
+ $logger.warn("Unauthorized(##{client.user_id})")
+ send_chunk("UNAUTHORISED #{client.row_id}&#{client.user_id}")
+ client.stop_stream
+ @clients.delete(client)
end
- con.on_forbidden do
- $logger.error("Forbidden: #{con.options[:user_id]}")
- @connections.delete(con)
+ client.on_enhance_your_calm do
+ # limit?
+ $logger.warn("Enhance your calm(##{client.user_id})")
end
- con.on_not_found do
- $logger.error("Not Found: #{con.options[:user_id]}")
- @connections.delete(con)
+ client.on_no_data_received do
+ # (?)
+ $logger.warn("No data received(##{client.user_id})")
+ client.close_connection
end
- con.on_not_acceptable do
- $logger.error("Not Acceptable: #{con.options[:user_id]}")
+ client.on_reconnect do |timeout, retries|
+ $logger.warn("Reconnected(##{client.user_id}): #{retries}")
end
- con.on_too_long do
- $logger.error("Too Long: #{con.options[:user_id]}")
+ client.on_stall_warning do |warning|
+ $logger.info("Stall warning(##{client.user_id}): #{warning}")
end
- con.on_range_unacceptable do
- $logger.error("Range Unacceptable: #{con.options[:user_id]}")
+ client.on_timeline_status do |status|
+ # tweets. includes retweets
+ if status.retweeted_status && (status.retweeted_status.user.id == client.user_id ||
+ status.user.id == client.user_id)
+ send_retweet(status)
+ elsif status.user.id == client.user_id
+ send_tweet(status)
+ end
end
- con.on_enhance_your_calm do
- $logger.error("Enhance Your Calm: #{con.options[:user_id]}")
- @connections.delete(con)
+ client.on_event(:favorite) do |event|
+ send_favorite(Twitter::User.new(event[:source]), Twitter::Tweet.new(event[:target_object]))
end
- con.on_error do |message|
- $logger.error("Unknown: #{con.options[:user_id]}/#{message}")
+ client.on_event(:unfavorite) do |event|
+ send_unfavorite(Twitter::User.new(event[:source]), Twitter::Tweet.new(event[:target_object]))
end
- con.each do |chunk|
- begin # convert error
- begin
- status = ::Yajl::Parser.parse(chunk, :symbolize_keys => true)
- rescue ::Yajl::ParseError
- $logger.warn("::Yajl::ParseError in stream: #{chunk}")
- next
- end
-
- if status.is_a?(::Hash)
- if status.key?(:user)
- if status[:user][:id] == con.options[:user_id] &&
- !status.key?(:retweeted_status)
- send_tweet(status)
- $logger.debug("Created Tweet")
- elsif status.key?(:retweeted_status) &&
- (status[:retweeted_status][:user][:id] == con.options[:user_id] ||
- status[:user][:id] == con.options[:user_id])
- send_retweet(status)
- $logger.debug("Created Retweet")
- end
- elsif status[:event] == "favorite"
- if status[:target_object][:user] &&
- (!status[:target_object][:user][:protected] ||
- status[:target_object][:user][:id] == con.options[:user_id])
- send_favorite(status)
- $logger.debug("Created Favorite")
- end
- elsif status[:event] == "unfavorite"
- send_unfavorite(status)
- $logger.debug("Destroyed Favorite")
- elsif status.key?(:delete) && status[:delete].key?(:status)
- send_delete(status)
- $logger.debug("Destroyed Tweet: #{status[:delete][:status][:id]}/#{status[:delete][:status][:user_id]}")
- else
- # monyo
- end
- else
- $logger.warn("Unexpected object in stream: #{status}")
- next
- end
- rescue # debug
- $logger.error($!)
- $logger.error($@)
- end
+ client.on_delete do |status_id, user_id|
+ send_delete(status_id, user_id)
end
- $logger.info("User connected: #{con.options[:user_id]}")
- @connections << con
+ client.userstream
+ $logger.info("Connected(##{client.user_id})")
rescue ::Yajl::ParseError
$logger.error("JSON Parse Error: #{json}")
end
@@ -231,8 +222,8 @@ def receive_data(data)
end
def stop_all
- @connections.map(&:stop)
- send_data("QUIT\r\n")
+ @clients.map(&:stop_stream)
+ send_chunk("QUIT")
end
end
@@ -243,13 +234,14 @@ def initialize
def start
$logger.info("Worker ##{Settings.worker_number} started")
EM.run do
+ connection = EM.connect(Settings.db_proxy_host, Settings.db_proxy_port, DBProxyClient)
+
stop = Proc.new do
+ connection.stop_all
EM.stop
end
Signal.trap(:INT, &stop)
Signal.trap(:TERM, &stop)
-
- EM.connect(Settings.db_proxy_host, Settings.db_proxy_port, DBProxyClient)
end
end
end
View
63 config/database.yml
@@ -1,13 +1,52 @@
-<% #development:
- #test:
- #production:
- # adapter: mysql2
- # encoding: utf8
- # reconnect: true
- # database: production
- # pool: 5
- # username: <%= ENV["DOTCLOUD_DB_MYSQL_LOGIN"] %>
- # password: <%= ENV["DOTCLOUD_DB_MYSQL_PASSWORD"] %>
- # host: <%= ENV["DOTCLOUD_DB_MYSQL_HOST"] %>
- # port: <%= ENV["DOTCLOUD_DB_MYSQL_PORT"] %>
+<%
+require 'cgi'
+require 'uri'
+
+begin
+ uri = URI.parse(ENV["DATABASE_URL"])
+rescue URI::InvalidURIError
+ raise "Invalid DATABASE_URL"
+end
+
+raise "No RACK_ENV or RAILS_ENV found" unless ENV["RAILS_ENV"] || ENV["RACK_ENV"]
+
+def attribute(name, value, force_string = false)
+ if value
+ value_string =
+ if force_string
+ '"' + value + '"'
+ else
+ value
+ end
+ "#{name}: #{value_string}"
+ else
+ ""
+ end
+end
+
+adapter = uri.scheme
+adapter = "postgresql" if adapter == "postgres"
+
+database = (uri.path || "").split("/")[1]
+
+username = uri.user
+password = uri.password
+
+host = uri.host
+port = uri.port
+
+params = CGI.parse(uri.query || "")
+
%>
+
+<%= ENV["RAILS_ENV"] || ENV["RACK_ENV"] %>:
+ <%= attribute "adapter", adapter %>
+ <%= attribute "database", database %>
+ <%= attribute "username", username %>
+ <%= attribute "password", password, true %>
+ <%= attribute "host", host %>
+ <%= attribute "port", port %>
+
+<% params.each do |key, value| %>
+ <%= key %>: <%= value.first %>
+<% end %>
View
14 config/routes.rb
@@ -10,12 +10,12 @@
get "i/logout" => "sessions#destroy"
get "i/:id" => "i#show", :constraints => constraints
- get "(users)/:screen_name/status(es)/:id" => "i#show", :constraints => constraints
+ get ":screen_name/status(es)/:id" => "i#show", :constraints => constraints
- get "(users)/:screen_name(/:page)" => "users#best", :constraints => constraints
- get "(users)/:screen_name/my(/:page)" => "users#my", :constraints => constraints
- get "(users)/:screen_name/discovered(/:page)" => "users#my", :constraints => constraints
- get "(users)/:screen_name/timeline(/:page)" => "users#timeline", :constraints => constraints
- get "(users)/:screen_name/recent(/:page)" => "users#recent", :constraints => constraints
- get "(users)/:screen_name/info(/:page)" => "users#info", :constraints => constraints
+ get ":screen_name(/:page)" => "users#best", :constraints => constraints
+ get ":screen_name/my(/:page)" => "users#my", :constraints => constraints
+ get ":screen_name/discovered(/:page)" => "users#my", :constraints => constraints
+ get ":screen_name/timeline(/:page)" => "users#timeline", :constraints => constraints
+ get ":screen_name/recent(/:page)" => "users#recent", :constraints => constraints
+ get ":screen_name/info(/:page)" => "users#info", :constraints => constraints
end
View
6 lib/receiver/start.rb
@@ -0,0 +1,6 @@
+Receiver::Worker.spawn!({:working_dir => Rails.root,
+ :pid_file => File.join(Rails.root, "tmp", "pids", "receiver.pid"),
+ :log_file => File.join(Rails.root, "log", "receiver.log"),
+ :sync_log => true,
+ :singleton => true})
+
View
23 lib/receiver/worker.rb
@@ -8,11 +8,12 @@ def send_chunk(data)
end
end
-class Receiver::Worker
+class Receiver::Worker < DaemonSpawn::Base
class DBProxyServer < EM::Connection
$worker_count = nil
@@wq = EM::WorkQueue::WorkQueue.new do |arg|
begin
+ begin
json = ::Yajl::Parser.parse(arg.last, :symbolize_keys => true)
rescue ::Yajl::ParseError
# JSON parse error....??
@@ -69,6 +70,10 @@ class DBProxyServer < EM::Connection
# ???
puts "???????"
end
+ rescue
+ $logger.error($!)
+ $logger.error($@)
+ end
end
@@wq.start
@@ -102,7 +107,6 @@ def receive_data(data)
while line = @receive_buf.slice!(/.+?\r\n/)
line.chomp!
next if line == ""
- p line
arg = line.split(/ /, 2)
case arg.first
when "CONNECT"
@@ -129,6 +133,7 @@ def receive_data(data)
close_connection_after_writing
end
when "QUIT"
+ $logger.info("Quit: #{@worker_number}")
send_chunk("BYE")
close_connection_after_writing
else
@@ -144,7 +149,6 @@ def initialize
end
def post_init
- p "connected"
end
def receive_data(data)
@@ -182,23 +186,30 @@ def receive_data(data)
end
end
- def initialize
- $logger = Receiver::Logger.new(:info)
+ def initialize(opts = {})
+ super(opts)
+ $logger = Receiver::Logger.new(:warn)
$connections = {}
end
- def start
+ def start(args)
$logger.info("Database Proxy Started")
EM.run do
stop = Proc.new do
EM.stop
end
Signal.trap(:INT, &stop)
+ Signal.trap(:QUIT, &stop)
Signal.trap(:TERM, &stop)
EM.start_server("0.0.0.0", Settings.db_proxy_port, DBProxyServer)
EM.start_unix_domain_server(Settings.register_server_path, RegisterServer)
end
end
+
+ def stop
+ end
end
+
+

0 comments on commit 2c56dbd

Please sign in to comment.