eventmachine

Install OpenSSL with Ruby for eventmachine on Windows 7 x86

我与影子孤独终老i 提交于 2019-12-01 03:23:21
问题 Install OpenSSL with Ruby for eventmachine on Windows 7 x86. I want to install eventmachine gem on Windows 7 x86 SP1. I have installed rubyinstaller-2.1.5.exe from http://rubyinstaller.org/downloads/ I have also installed DevKit-mingw64-32-4.7.2-20130224-1151-sfx.exe . I run command: gem install eventmachine --platform=ruby As for now this is to use eventmachine-1.0.4 . I got following console output: Temporarily enhancing PATH to include DevKit... Building native extensions. This could take

How to catch top level failures on an EventMachine server?

守給你的承諾、 提交于 2019-12-01 02:02:07
问题 I have an EventMachine server that I am monitoring with monit. Sometimes it crashes, and I am trying to figure out why, but it is unclear to me how I can just log all top level failures. I tried code like this: begin EventMachine::run do EventMachine::start_server('0.0.0.0', PORT, MyServer) end rescue Exception => e puts "FAILURE: #{e.class}: #{e}" end but that does not seem to ever catch errors. I suspect it might be something like running out of memory, which I am tracking separately, but

Multiple servers in a single EventMachine reactor

ぃ、小莉子 提交于 2019-11-30 05:14:30
问题 Is it possible to run multiple servers within a single event machine? What I mean is that multiple services can be used concurrently by a single client connection. For example, a login server authenticates a user and then a user can use both a chat room and a simple game such as checkers with a single client socket concurrently? Or do I need multiple eventmachine reactors for each service? 回答1: I tried this and it's working: #!/usr/bin/env ruby require 'eventmachine' module EchoServer def

How to decode a cookie from the header of a websocket connection handshake? (Ruby)

我们两清 提交于 2019-11-29 11:21:29
I am running a Sinatra app within an EventMachine.run loop and in my ws.onopen method I wish to check the handshake header's cookie to ensure that the incoming request is coming from a registered user of my webapp. My Sinatra app includes the following: use Rack::Session::Cookie, :key => COOKIE_KEY, :path => '/', :expire_after => 2592000, #30 days :secret => COOKIE_SECRET and my ws.onopen method looks like this (trimmed) ws.onopen { |handshake| cookie, bakesale = handshake.headers['Cookie'].split('=') rack_cookie = Rack::Session::Cookie.new(MyApp, { :key => COOKIE_KEY, :path => '/', :expire

Rails/Ruby Error When Creating Database: Unable to load the EventMachine C extension

血红的双手。 提交于 2019-11-29 07:22:13
Update: the eventmachine gem is installed and in my gemfile: eventmachine (1.0.0, 0.12.10) Please help! Trying to create a database with the following: Fitzs-MacBook-Pro:twilio_insanity Fitz$ rake db:create' Returns the following error: Unable to load the EventMachine C extension; To use the pure-ruby reactor, require 'em/pure_ruby' rake aborted! cannot load such file -- rubyeventmachine /Users/Fitz/.rvm/gems/ruby-1.9.3-p327@rails3tutorial2ndEd/gems/eventmachine-1.0.0/lib/eventmachine.rb:8:in require' /Users/Fitz/.rvm/gems/ruby-1.9.3-p327@rails3tutorial2ndEd/gems/eventmachine-1.0.0/lib

What is the best way to read files in an EventMachine-based app?

风格不统一 提交于 2019-11-29 03:50:29
In order not to block the reactor I would like to read files asynchronously, but I've found no obvious way of doing it using EventMachine. I've tried a few different approaches, but none of them feels right: Just read the file, it'll block the reactor, but what the hell, it's not that slow (unless it's a big file, and then it definitely is). Open the file for reading and read a chunk on each tick (but how much to read? too much and it'll block the reactor, too little and reading will get slower than necessary). EM.popen('cat some/file', FileReader) feels really weird, but works better than the

async requests using sinatra streaming API

﹥>﹥吖頭↗ 提交于 2019-11-28 08:36:11
问题 I use async_sinatra gem to implement asynchronous routes, but I came across a post somewhere that said that Sinatra's streaming API can be used instead of async_sinatra for this purpose. Can the same functionality as below be implemented using streaming? require 'em-hiredis' require 'sinatra/async' class App < Sinatra::Base register Sinatra::Async def redis @redis ||= EM::Hiredis.connect end aget '/' do redis.blpop('abcdef', 15). callback {|x| body "x=#{x}"}. errback {|e| body "e=#{e}"} end

Any success with Sinatra working together with EventMachine WebSockets?

半腔热情 提交于 2019-11-28 02:57:39
I have been using Sinatra for sometime now and I would like to add some realtime features to my web-app by pushing the data via websockets. I have successfully used the gem 'em-websocket' on its own, but have not been able to write one ruby file that has a sinatra web server AND a web-socket server. I've tried spinning the run! or start! methods off in separate threads with no success. Has anyone gotten this to work? I want to have them in the same file as I can then share variables between the two servers. Thanks! Konstantin Haase Did not try it, but should not be too hard: require 'em

What is the difference between event driven model and reactor pattern? [closed]

守給你的承諾、 提交于 2019-11-28 02:32:39
From the wikipedia Reactor Pattern article: The reactor design pattern is an event handling pattern for handling service requests delivered concurrently to a service handler by one or more inputs. It named a few examples, e.g. nodejs , twisted , eventmachine But what I understand that above is popular event driven framework, so make them also a reactor pattern framework? How to differentiate between these two? Or they are the same? The reactor pattern is more specific than "event driven programming". It is a specific implementation technique used when doing event driven programming. However,

Rails - cannot run app: Unable to load the EventMachine C extension;

回眸只為那壹抹淺笑 提交于 2019-11-28 01:22:16
When I run an app on Lion OS X, I get this error: Unable to load the EventMachine C extension; To use the pure-ruby reactor, require 'em/pure_ruby' /Users/adam/.rvm/gems/ruby-1.9.2-p290/gems/eventmachine-1.0.0/lib/eventmachine.rb:8:in `require': no such file to load -- rubyeventmachine (LoadError) from /Users/adam/.rvm/gems/ruby-1.9.2-p290/gems/eventmachine-1.0.0/lib/eventmachine.rb:8:in `<top (required)>' from /Users/adam/.rvm/gems/ruby-1.9.2-p290@global/gems/bundler-1.0.21/lib/bundler/runtime.rb:68:in `require' from /Users/adam/.rvm/gems/ruby-1.9.2-p290@global/gems/bundler-1.0.21/lib/bundler