April 20 - posted a fix to chapter 9:
- Make sure you have all the prerequisites installed:
Rails 2.0.2 or edge
Json gem (gem install json)
EventMachine gem (gem install eventmachine) - Install the GEM -
sudo gem install juggernaut
- Create a new Rails APP -
rails koko
- Enter it's dir -
cd koko
- Install the Juggernaut plugin -
ruby script/plugin install
http://juggernaut.rubyforge.org/svn/trunk/juggernaut - Paste this inside koko/juggernaut.yml -
http://pastie.caboo.se/179083 - Paste this inside koko/config/juggernaut_hosts.yml -
http://pastie.caboo.se/179077 - Paste this inside koko/app/controllers/chat_controller.rb -
http://pastie.caboo.se/179079 - Paste this inside koko/app/views/chat/index.rhtml -
http://pastie.caboo.se/179073 - *FOR UBUNTU ONLY (and maybe other linux distors too):
export PATH=$PATH:/var/lib/gems/1.8/bin(add it to your bash.profile too)
or use /var/lib/gems/1.8/bin/juggernaut in the next phase - Run the Juggernaut Server -
juggernaut -c juggernaut.yml
"Starting Juggernaut server on port: 5001..." is the answer you than expect - Run the Rails Server -
script/server
- Browse to -
http://localhost:3002/chat?send_to_channel=1&listen_to_channel=1
You will be sending and receiving through the channel numbers specified in the QueryString
You can use either "RAILS SEND" to send through the Rails Server or "JS SEND" to use the Ruby Server only ( YES - it will work with your Rails server down)
Notice that I've "faked" a firebug-like console on the right, to see all Juggernaut logs in realtime even if you're not using firebug.
The input from the listened-to channel is shown on the left box.
Now, open another browser with the same URI and start chatting!
Resources:
http://juggernaut.rubyforge.org/
http://groups.google.com/group/Juggernaut-for-Rails








17 comments:
Newbie Alert!
Whats about the 'Juggernaut error. 'swf_name' must be unique per juggernaut instance.' -Error ?
Ups! I mean:
Thanks for the quick tutorial.
I´m a newbie and get the swf_name error.
Do anyone know anything about it?
Thanks!
Having the same problem,
'Juggernaut error. 'swf_name' must be unique per juggernaut instance.'
it shouldn't avoid you from working, though
go directly to http://localhost:3002/chat
(no parameters)
look at the console on the right,
it should show:
Juggernaut: Connected on 127.0.0.1:5001
look at the console on the left,
write something in the input box and click one of the buttons
it should be shown there
It works :)
thx
eventmachine tutorial
i really wanted to find an "eventmachine tutorial" so I googled for it and saw this post as the #1 result.
It was pretty frustrating, as there is no doubt it won't help me.
"Life is not without a sense of Irony." Morpheus, Matrix
Dor,
I tried your tutorial on a Ubuntu 7.10 server, with Rails 2.02.
All I get is a blank page. The swf object appears to be there, and the javascript, but no data at all. No errors in firebug until I hit a button.
any ideas?
John Fisher
dear john,
have you used the URL:
http://localhost:3002/chat?send_to_channel=1&listen_to_channel=1
?
Thanks Dor,
I tried your suggestion and still nothing... In my case its a separate server and mongrel just-happens-to-be running on port 3000 so I used
http://ip.ip.ip.ip:3000/chat?send_to_channel=1&listen_to_channel=1
Let me be clear: the text and javascript elements are coming through but the boxes are empty as are the channel numbers. I tried deleting the cookie too as suggested elsewhere.
Any other ideas?
John
Great job, dor kalev!
just one little question, I set it up on windows with instantRails. Everything seems to be ok except I can't chat in channels, I can send and receive messages in http://localhost:3000/chat with no parameters, but it doesn't want to work in channels, I'll simply got nothing after I hit either send button. There's nothing in the right window, it just says: Juggernaut: Connected on 127.0.0.1:5001.
Also, juggernaut wouldn't work if I refresh the page as well.
Does anyone know about this? Thanks.
-Terrance
Hey guys , got Juggernaut wrapped up...
Follow the steps in the below link hack it..
http://ctrlshiftesc.wordpress.com/2008/08/26/installing-juggernaut-gem-headache-painkiller/
i almost gave up on this but i got it at last. i would like to share the experience, the main problem is installing sqlite3, json and evenmachine, the latest versions dont necessarily work on rails in windows. try the ignore dependencies option for evenmachine, and use the link by the guy above or json, also sqlite will require some doing. the remote list all option for gem should be tried for sqlite3 and choose a suitable older version that works on windows
I had some trouble because pastie seems to do funky things with your view example code. I wound up grabbing (what I hope is) the right thing out of the page source, but the actual visible version seems very broken -- it's interpreting your HTML inline.
I'm using FireFox 3.0.7.
-Noah
I'm having trouble with this, now that I've put it together. Specifically, even after installing the sqlite3 gem and Ruby OpenSSL extension. Specifically, I'm getting the following:
angelbob@devel:~/rails/frontporch$ ./script/server
=> Booting WEBrick
=> Rails 2.3.2 application starting on http://0.0.0.0:3000
=> Call with -d to detach
=> Ctrl-C to shutdown server
[2009-03-28 14:06:03] INFO WEBrick 1.3.1
[2009-03-28 14:06:03] INFO ruby 1.8.7 (2008-08-11) [i686-linux]
[2009-03-28 14:06:03] WARN TCPServer Error: Address already in use - bind(2)
[2009-03-28 14:06:03] INFO WEBrick::HTTPServer#start: pid=22016 port=3000
Processing ChatController#index (for ::ffff:12.7.175.2 at 2009-03-28 14:06:13) [GET]
Parameters: {"send_to_channel"=>"1", "listen_to_channel"=>"1"}
Rendering chat/index
DEPRECATION WARNING: ActionController::Session::AbstractStore::SessionHash#session_id has been deprecated. Please use request.session_options[:id] instead.. (called from _run_rhtml_app47views47chat47index46rhtml at /home/angelbob/rails/frontporch/app/views/chat/index.rhtml:63)
Completed in 14ms (View: 12, DB: 0) | 200 OK [http://arch.angelbob.com/chat?send_to_channel=1&listen_to_channel=1]
Processing ChatController#index (for ::ffff:12.7.175.2 at 2009-03-28 14:06:19) [GET]
Parameters: {"send_to_channel"=>"1", "listen_to_channel"=>"1"}
Rendering chat/index
DEPRECATION WARNING: ActionController::Session::AbstractStore::SessionHash#session_id has been deprecated. Please use request.session_options[:id] instead.. (called from _run_rhtml_app47views47chat47index46rhtml at /home/angelbob/rails/frontporch/app/views/chat/index.rhtml:63)
Completed in 4ms (View: 2, DB: 0) | 200 OK [http://arch.angelbob.com/chat?send_to_channel=1&listen_to_channel=1]
Processing ChatController#send_data (for ::ffff:12.7.175.2 at 2009-03-28 14:06:47) [POST]
Parameters: {"commit"=>"RAILS SEND", "send_to_channel"=>"1", "chat_input"=>""}
NameError (undefined local variable or method `add_variables_to_assigns' for #<ChatController:0xb756036c>):
app/controllers/chat_controller.rb:9:in `send_data'
/usr/local/lib/ruby/1.8/webrick/httpserver.rb:104:in `service'
/usr/local/lib/ruby/1.8/webrick/httpserver.rb:65:in `run'
/usr/local/lib/ruby/1.8/webrick/server.rb:173:in `start_thread'
/usr/local/lib/ruby/1.8/webrick/server.rb:162:in `start'
/usr/local/lib/ruby/1.8/webrick/server.rb:162:in `start_thread'
/usr/local/lib/ruby/1.8/webrick/server.rb:95:in `start'
/usr/local/lib/ruby/1.8/webrick/server.rb:92:in `each'
/usr/local/lib/ruby/1.8/webrick/server.rb:92:in `start'
/usr/local/lib/ruby/1.8/webrick/server.rb:23:in `start'
/usr/local/lib/ruby/1.8/webrick/server.rb:82:in `start'
Rendered rescues/_trace (35.4ms)
Rendered rescues/_request_and_response (1.4ms)
Rendering rescues/layout (internal_server_error)
Ah! That's what's wrong. This isn't updated to the GIThub version of Juggernaut, so it's no longer working with the latest stable Rails.
Has anyone been able to deploy a jnaut service on bluehost? I have had them opened the port 5001 for incoming and then for outgoing with no success. My views keep trying for three times with no successful connected to juggernaut! Please help if you have an answer.
babake: i dont know about bluehost but i managed to do it on joyent back then...
Post a Comment