Skip to content

Commit

Permalink
Adds thin and sets up Faye in config.ru
Browse files Browse the repository at this point in the history
Signed-off-by: Akash Manohar J <[email protected]>
  • Loading branch information
HashNuke committed Mar 6, 2012
1 parent 0c7890d commit 064341d
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 1 deletion.
2 changes: 2 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ gem 'sqlite3'
gem 'devise'
gem 'devise_bushido_authenticatable'
gem 'bushido'
gem 'thin'
gem 'faye'

# Gems used only for assets and not required
# in production environments by default.
Expand Down
29 changes: 29 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ GEM
activesupport (3.2.2)
i18n (~> 0.6)
multi_json (~> 1.0)
addressable (2.2.7)
arel (3.0.2)
bcrypt-ruby (3.0.1)
builder (3.0.0)
Expand All @@ -71,6 +72,8 @@ GEM
coffee-script-source
execjs
coffee-script-source (1.2.0)
cookiejar (0.3.0)
daemons (1.1.8)
devise (1.5.3)
bcrypt-ruby (~> 3.0)
orm_adapter (~> 0.0.3)
Expand All @@ -79,17 +82,36 @@ GEM
devise (= 1.5.3)
rubycas-client (>= 2.2.1)
diff-lcs (1.1.3)
em-http-request (1.0.1)
addressable (>= 2.2.3)
cookiejar
em-socksify
eventmachine (>= 1.0.0.beta.4)
http_parser.rb (>= 0.5.3)
em-socksify (0.1.0)
eventmachine
erubis (2.7.0)
eventmachine (1.0.0.beta.4)
execjs (1.3.0)
multi_json (~> 1.0)
factory_girl (2.6.1)
activesupport (>= 2.3.9)
factory_girl_rails (1.7.0)
factory_girl (~> 2.6.0)
railties (>= 3.0.0)
faye (0.8.0)
cookiejar (>= 0.3.0)
em-http-request (>= 0.3.0)
eventmachine (>= 0.12.0)
faye-websocket (>= 0.4.0)
rack (>= 1.0.0)
yajl-ruby (>= 1.0.0)
faye-websocket (0.4.1)
eventmachine (>= 0.12.0)
ffi (1.0.11)
highline (1.6.11)
hike (1.2.1)
http_parser.rb (0.5.3)
i18n (0.6.0)
jasmine-core (1.2.0.rc1)
journey (1.0.3)
Expand Down Expand Up @@ -168,6 +190,10 @@ GEM
sqlite3 (1.3.5)
therubyracer (0.9.10)
libv8 (~> 3.3.10)
thin (1.3.1)
daemons (>= 1.0.9)
eventmachine (>= 0.12.6)
rack (>= 1.0.0)
thor (0.14.6)
tilt (1.3.3)
treetop (1.4.10)
Expand All @@ -181,6 +207,7 @@ GEM
rack (>= 1.0)
xpath (0.1.4)
nokogiri (~> 1.3)
yajl-ruby (1.1.0)

PLATFORMS
ruby
Expand All @@ -193,6 +220,7 @@ DEPENDENCIES
devise_bushido_authenticatable
ember-rails!
factory_girl_rails
faye
jasmine!
jquery-rails
rails (= 3.2.2)
Expand All @@ -201,4 +229,5 @@ DEPENDENCIES
shoulda-matchers
sqlite3
therubyracer
thin
uglifier (>= 1.0.3)
1 change: 1 addition & 0 deletions app/views/layouts/application.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
<title>Kandan</title>
<%= stylesheet_link_tag "application", :media => "all" %>
<%= javascript_include_tag "application" %>
<%= javascript_include_tag "#{ENV['FAYEJS']}.js" %>
<%= csrf_meta_tags %>
</head>
<body>
Expand Down
26 changes: 25 additions & 1 deletion config.ru
Original file line number Diff line number Diff line change
@@ -1,4 +1,28 @@
# This file is used by Rack-based servers to start the application.

require ::File.expand_path('../config/environment', __FILE__)
run Kandan::Application
require 'faye'

faye_server = Faye::RackAdapter.new(:mount => "/faye", :timeout => 5)

# TODO send pull request to faye to get this fixed
# by adding a rack_prefix option
# which should then make the faye server object available
# via the get_client() method on the server

FAYE_CLIENT = faye_server.get_client

faye_server.bind(:subscribe) do |client_id|
puts "SUBSCRIBE #{client_id}"
end

faye_server.bind(:disconnect) do |client_id|
puts "DISCONNECT #{client_id}"
end

run Rack::URLMap.new({
"/remote" => faye_server,
"/" => Kandan::Application
})

# run Kandan::Application
1 change: 1 addition & 0 deletions config/initializers/faye.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ENV['FAYEJS'] ||= "/remote/faye"

0 comments on commit 064341d

Please sign in to comment.